{% macro tree(Category) %}
{% from _self import tree %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}"{% if Category.children|length > 0 %}class="toggle"{% endif %} >
{{ Category.name }}
</a>
{% if Category.children|length > 0 %}
<ul class="child_categories">
{% for ChildCategory in Category.children %}
<li data-category-id="{{ ChildCategory.id }}">
{{ tree(ChildCategory) }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
<!--indexでの呼び出し:.indexcat-->
{% set Categories = repository('Eccube\\Entity\\Category').getList() %}
{% from _self import tree %}
<ul class="catelist2">
<li class="allitem">
<a class="iconimg00" href="{{ url('product_list') }}?mode=&category_id=&name=&pageno=1&disp_number=30">全ての商品</a>
</li>
{% for c in Categories %}
{% if c.School is not null and c.School.school_id == app.user.School.school_id %}
<li data-category-id="{{ c.id }}" class="top_category">
{{ tree(c) }}
</li>
{% endif %}
{% endfor %}
{% if(SetProductCount > 0) %}
<li{% if product_type is defined and product_type=='set' %} class="activ"{% endif %}><a class="iconimg13" href="{{ url('product_list') }}?product_type=set">セット</a></li>
{% endif %}
</ul>