I have an issue with categories with different levels:

I have a group of categories which have a structure like this:

First form: 1.0 Group – 1.1 Subgroup – 1.2 Items in subgroup

Second form: - 1.0 Group – 1.1 Items in Group

In some groups are subgroups in others aren't. But I need to list all the items, regardless if they are in a subgroup or not. How can I adress them correctly. Can I do an if statement like: if there is no 1.2 level, take the 1.1 level and treat it like a 1.2 level?

How can I do this?

1 Answer 1


What you want is the categories that do not have descendants. I would loop over all the categories, and skip the ones with descendants. The test to skip is:

{% if not category.hasDescendants %} ... {% endif %}

Documentation for hasDescendants.

  • Phantastic! That does the trick! Very cool! Thank you very much Marion! Commented Jan 19, 2018 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.