加多一个ul就可以,category.children下其实还有一个children
<div class="category-module"> <!--h3>{{heading_title}}</h3-->
<ul class="list-unstyled">
{% for category in categories %}
{% if category.category_id == category_id %}
<li><a href="{{ category.href }}" class=" active">{{ category.name }}</a></li>
{% if category.children %}
<ul class="list-child">
{% for child in category.children %}
<li><a href="{{ child.href }}" class="{% (child.category_id==child_id) ? 'active':'' %}">{{ child.name }}</a></li>
<ul class="list-child">
{% for grandchildren in child.children %}
<li><a href="{{ grandchildren.href }}" class="">{{ grandchildren.name }}</a></li>
{% endfor %}
</ul>
{% endfor %}
</ul>
{% endif %}
{% else %}
<li><a href="{{ category.href }}" class="">{{ category.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
</div> 司徒浩 发表于 2020-7-19 11:07
不行,还是不显示第三级菜单
已经修改好了 司徒浩 发表于 2020-7-19 11:31
还是不行Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'A block must start with...
这个应该可以了
<div class="category-module"> <!--h3>{{heading_title}}</h3-->
<ul class="list-unstyled">
{% for category in categories %}
{% if category.category_id == category_id %}
<li><a href="{{ category.href }}" class=" active">{{ category.name }}</a></li>
{% if category.children %}
<ul class="list-child">
{% for child in category.children %}
<li><a href="{{ child.href }}" class="{{ (child.category_id==child_id) ? 'active':'' }}">{{ child.name }}</a></li>
<ul class="list-child">
{% for grandchildren in child.children %}
<li><a href="{{ grandchildren.href }}" class="">{{ grandchildren.name }}</a></li>
{% endfor %}
</ul>
{% endfor %}
</ul>
{% endif %}
{% else %}
<li><a href="{{ category.href }}" class="">{{ category.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
页:
[1]
2