{% sw_extends '@Storefront/storefront/layout/sidebar/category-navigation.html.twig' %}
{# we start with level 2, level 1 is never used: Einstiegskategorie #}
{# only show children categories #}
{% block layout_navigation_categories_list %}
{% if activeResult.level == 2 %}
{% for item in navigationTree %}
{# display children categories of current category #}
{% if item.category.id == activeResult.id %}
<ul class="category-navigation-wrapper--list">
{% for item in item.children %}
<li class="category-navigation-entry">
<a class="category-navigation-link" href="{{ category_url(item.category) }} {% if category_linknewtab(item.category) %}target="_blank"{% endif %}">
{{ item.category.translated.name }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
{% elseif activeResult.level == 3 %}
{% for item in navigationTree %}
{# if category id in active path, go down this category one level to reach the children #}
{% if item.category.id in activeResult.path %}
{# 3. level #}
{% for child in item.children %}
{% if child.category.id == activeResult.id %}
{# if active category has subcategories: show #}
{% if child.children %}
<ul class="category-navigation-wrapper--list">
{% for item in child.children %}
<li class="category-navigation-entry">
<a class="category-navigation-link" href="{{ category_url(item.category) }}
{% if category_linknewtab(item.category) %}target="_blank"{% endif %}">
{{ item.category.translated.name }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}