hierarchical-taxonomy-menu.html.twig in Hierarchical Taxonomy Menu 8
{% macro menu_links(menu_tree, route_tid, current_depth, max_depth, collapsible) %}
{% import _self as macros %}
{% for item in menu_tree %}
{%
set liClass = [
item.subitem and current_depth < max_depth ? 'menu-item menu-item--expanded block-taxonomymenu__menu-item block-taxonomymenu__menu-item--expanded' : 'menu-item block-taxonomymenu__menu-item',
route_tid == item.tid ? 'menu-item--active block-taxonomymenu__menu-item--active' : ''
]
%}
<li class="{{ liClass|join(' ') }}">
{% if item.image %}
<img class="menu-item-image block-taxonomymenu__image" src="{{ item.image }}" alt="{{ item.name }}" {% if item.use_image_style == false %}height="{{ item.height }}" width="{{ item.width }}"{% endif %} />
{% endif %}
<a href="{{ item.url }}" class="block-taxonomymenu__link {% if route_tid == item.tid %}active block-taxonomymenu__link--active{% endif %}">{{ item.name }}{% if item.show_count == true %} [{{ item.entities|length }}]{% endif %}</a>
{% if item.subitem and current_depth < max_depth %}
{% if item.interactive_parent %}
<i class="arrow-right parent-toggle" aria-hidden="true"></i><span class="visually-hidden">Expand Secondary Navigation Menu</span>
{% endif %}
{% if collapsible == TRUE %}
<ul class="menu block-taxonomymenu__submenu collapsed-submenu">
{% else %}
<ul class="menu block-taxonomymenu__submenu">
{% endif %}
{{ macros.menu_links(item.subitem, route_tid, current_depth + 1, max_depth, collapsible) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% import _self as macros %}
<ul class="menu hierarchical-taxonomy-menu block-taxonomymenu__menu">
{{ macros.menu_links(menu_tree, route_tid, 0, max_depth, collapsible) }}
</ul>
File
templates/hierarchical-taxonomy-menu.html.twig
View source
- {% macro menu_links(menu_tree, route_tid, current_depth, max_depth, collapsible) %}
- {% import _self as macros %}
- {% for item in menu_tree %}
- {%
- set liClass = [
- item.subitem and current_depth < max_depth ? 'menu-item menu-item--expanded block-taxonomymenu__menu-item block-taxonomymenu__menu-item--expanded' : 'menu-item block-taxonomymenu__menu-item',
- route_tid == item.tid ? 'menu-item--active block-taxonomymenu__menu-item--active' : ''
- ]
- %}
- <li class="{{ liClass|join(' ') }}">
- {% if item.image %}
- <img class="menu-item-image block-taxonomymenu__image" src="{{ item.image }}" alt="{{ item.name }}" {% if item.use_image_style == false %}height="{{ item.height }}" width="{{ item.width }}"{% endif %} />
- {% endif %}
- <a href="{{ item.url }}" class="block-taxonomymenu__link {% if route_tid == item.tid %}active block-taxonomymenu__link--active{% endif %}">{{ item.name }}{% if item.show_count == true %} [{{ item.entities|length }}]{% endif %}</a>
- {% if item.subitem and current_depth < max_depth %}
- {% if item.interactive_parent %}
- <i class="arrow-right parent-toggle" aria-hidden="true"></i><span class="visually-hidden">Expand Secondary Navigation Menu</span>
- {% endif %}
- {% if collapsible == TRUE %}
- <ul class="menu block-taxonomymenu__submenu collapsed-submenu">
- {% else %}
- <ul class="menu block-taxonomymenu__submenu">
- {% endif %}
- {{ macros.menu_links(item.subitem, route_tid, current_depth + 1, max_depth, collapsible) }}
- </ul>
- {% endif %}
- </li>
- {% endfor %}
- {% endmacro %}
-
- {% import _self as macros %}
- <ul class="menu hierarchical-taxonomy-menu block-taxonomymenu__menu">
- {{ macros.menu_links(menu_tree, route_tid, 0, max_depth, collapsible) }}
- </ul>