I have a small problem with looping in Twig.
How to loop the whole sub-nav
? Currently it makes sub-nav
in sub-nav
nested.
{% if categories %}
{% for category in categories %}
<ul class="sub-nav">
<li>
<a href="{{ category.href }}" class="cat-name">{{ category.name }}</a>
<ul class="sub-sub-nav list-inline">
{% if category.children %}
<li class="list-inline">
<a class="sub-cat-name" href="">{% for children in category.children|batch(category.children|length / category.column|round(1, 'ceil')) %}</a>
<ul class="sub-cat-menu">
{% for child in children %}
<li><a href="{{ child.href }}">{{ child.name }}</a></li>
{% endfor %}
</ul>
{% endfor %}</li>
<a href="{{ category.href }}" class="see-all">{{ text_all }} {{ category.name }}</a>
</ul>
{% endif %}
</li>
{% else %}
<li><a href="{{ category.href }}">{{ category.name }}</a></li>
{% endfor %}
</ul>