Created
May 28, 2021 14:59
-
-
Save umkasanki/191358c50bfe729a88c7a56a9d84ef50 to your computer and use it in GitHub Desktop.
Craft CMS. Categories tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
{% for category in craft.categories.all() %} | |
{% if category.level == 1 %} | |
{% set children = category.getChildren() %} | |
<h4>{{ category.title }}</h4> | |
{% if children|length %} | |
<ul> | |
{% for subcategory in children %} | |
<li>{{ subcategory.title }}</li> | |
{% endfor %} | |
</ul> | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment