{% macro tree(Category, school) %}
{% from _self import tree %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}&s={{ school }}"{% 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, school) }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
<!--indexでの呼び出し:.indexcat-->
{% set Categories = repository('Eccube\\Entity\\Category').getList() %}
{% from _self import tree %}
{% if app.user.school.isBrotherEnabled and app.user.visible_brothers %}
<ul>
<li class="allitem">
<a class="iconimg00" href="{{ url('product_list') }}?mode=&category_id=&name=&pageno=1&disp_number=30">全ての商品</a>
</li>
<li class="catelist1">
<p>{{ app.user.school.school_name }}</p>
<ul class="catelist2">
<li class="allitem">
<a class="iconimg00" href="{{ url('product_list') }}?mode=&category_id=&name=&pageno=1&disp_number=30&s={{ app.user.school.school_id }}">全ての商品</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, app.user.School.school_id) }}
</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>
</li>
{% for brother in app.user.visible_brothers %}
{% if brother.school and app.user.school.school_id != brother.school.school_id %}
<li>
<p>{{ brother.school.school_name }}</p>
<ul class="catelist2">
<li class="allitem">
<a class="iconimg00" href="{{ url('product_list') }}?mode=&category_id=&name=&pageno=1&disp_number=30&s={{ brother.school.school_id }}">全ての商品</a>
</li>
{% for c in Categories %}
{% if c.School is not null and c.School.school_id == brother.School.school_id %}
<li data-category-id="{{ c.id }}" class="top_category">
{{ tree(c, brother.School.school_id ) }}
</li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
{% else %}
<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, app.user.School.school_id) }}
</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>
{% endif %}