1

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?

2

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! – analog junkie Jan 19 '18 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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