3

I have 2 Main Groups of Categories, which themselves have Sub-Categories.
The Categories you see have checkboxes to filter entries below.
One Sub-Group has also Children (With Material/ Without Material) ->Screenshot.
I need to collapse these two groups (on click they open/close).
How can i target these Sub-sub-Category Groups?
Right now i use:

{% ifchildren %}
 <ul class="subcategory-list">
   {% children %}
 </ul>
{% endifchildren %}

enter image description here

I tried some with siblings but cannot get it to work. I also need to add extra html fot the arrow to indicate the collapse and to open the sublist.
If i add it right now, it gets added to all category-groups.
Thanks.

3

I'm not sure, but I think you might need to use level in your loop.

{% set categories = craft.categories.group('groupHandle').level(3) %}

{% for category in categories %}
    // etc
{% endfor %}

Have a look at the docs:

https://craftcms.com/docs/templating/craft.categories#level

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.