I have a 2 level category system. Some have children, some do not. How can I display entries related to the last level only?
If a category has no children, it should show the entries related to the 1st level. And if there are children, it should show entries related to that child category only.
The code below currently shows both levels, which I don't want. How can I tell Craft to look for the last (bottom) level only?
{% set entries = craft.entries.relatedTo(category).order('dateYear','comp_opus','title').limit(0) %}
{% for category in craft.categories.group('compositions').relatedTo(entries) %}
{% for entry in entries.relatedTo(category).limit(7) %}
{# Do stuff #}
{% endfor %}
{% endfor %}