{% extends 'knp_menu.html.twig' %}{% block list %} {% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %} {% import _self as knp_menu %} {% set listAttributes = listAttributes|merge({class: (listAttributes.class|default('') ~ ' nav-menu level-' ~ (item.level < 0 ? 0 : item.level - 1))}) %} {% if item.children|length > 0 and item.level > 0 %} {% set listAttributes = listAttributes|merge({class: (listAttributes.class|default('') ~ ' nav-child')}) %} <div class="collapse" id="collapse-{{ item.name|lower|slug }}" data-parent="#main-menu"> <ul{{ knp_menu.attributes(listAttributes) }}> {{ block('children') }} </ul> </div> {% else %} <ul{{ knp_menu.attributes(listAttributes) }}> {{ block('children') }} </ul> {% endif %} {% endif %}{% endblock %}{% block item %} {% if item.displayed %} {# building the class of the item #} {%- set classes = item.attribute('class') is not empty ? [item.attribute('class')] : [] %} {%- if matcher.isCurrent(item) %} {%- set classes = classes|merge([options.currentClass]) %} {%- elseif matcher.isAncestor(item, options.matchingDepth) %} {%- set classes = classes|merge([options.ancestorClass]) %} {%- endif %} {%- if item.actsLikeFirst %} {%- set classes = classes|merge([options.firstClass]) %} {%- endif %} {%- if item.actsLikeLast %} {%- set classes = classes|merge([options.lastClass]) %} {%- endif %} {% set classes = classes|merge(['nav-item']) %} {# Mark item as "leaf" (no children) or as "branch" (has children that are displayed) #} {% if item.hasChildren and options.depth is not same as(0) %} {% if options.branch_class is not empty and item.displayChildren %} {%- set classes = classes|merge([options.branch_class]) %} {% endif %} {% elseif options.leaf_class is not empty %} {%- set classes = classes|merge([options.leaf_class]) %} {%- endif %} {%- set attributes = item.attributes %} {%- if classes is not empty %} {%- set attributes = attributes|merge({'class': classes|join(' ')}) %} {%- endif %} {# displaying the item #} {% import _self as knp_menu %} {% set item_attr = attributes|filter((value, key) => key != 'icon') %} <li{{ knp_menu.attributes(item_attr) }}> {%- if item.children|length > 0 -%} {{ block('collapseElement') }} {%- elseif item.uri is not empty and (not matcher.isCurrent(item) or options.currentAsLink) %} {{ block('linkElement') }} {%- else %} {{ block('spanElement') }} {%- endif %} {# render the list of children #} {%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %} {%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' ') }) %} {{ block('list') }} </li> {% endif %}{% endblock %}{% block collapseElement %} {% import _self as knp_menu %} {% set collapse_attributes = item.labelAttributes %} {% if item.uri is not empty and (not matcher.isCurrent(item) or options.currentAsLink) %} {% set collapse_attributes = item.linkAttributes %} {% endif %} {% set additional_class = 'nav-link level-' ~ (item.level < 0 ? 0 : item.level - 1) ~ ' collapsed' ~ (matcher.isAncestor(item, options.matchingDepth) ? ' current-ancestor': '') %} {% set collapse_attributes = collapse_attributes|merge({class: (collapse_attributes.class|default('') ~ additional_class)}) %} <a href="#collapse-{{ item.name|lower|slug }}" data-bs-toggle="collapse" {{ knp_menu.attributes(collapse_attributes) }}> {{ block('label') }} </a>{% endblock %}{% block linkElement %} {% import _self as knp_menu %} {% set element_attributes = item.linkAttributes %} {% set additional_class = 'nav-link level-' ~ (item.level < 0 ? 0 : item.level - 1) ~ (matcher.isCurrent(item) ? ' active' : '') ~ (matcher.isAncestor(item, options.matchingDepth) ? ' current-ancestor': '') %} {% set element_attributes = element_attributes|merge({class: (element_attributes.class|default('') ~ additional_class)}) %} <a href="{{ item.uri }}"{{ knp_menu.attributes(element_attributes) }}> {{ block('label') }} </a>{% endblock %}{% block spanElement %} {% import _self as knp_menu %} {% set element_attributes = item.labelAttributes %} {% set additional_class = 'nav-link level-' ~ (item.level < 0 ? 0 : item.level - 1) ~ (matcher.isCurrent(item) ? ' active' : '') ~ (matcher.isAncestor(item, options.matchingDepth) ? ' current-ancestor': '') %} {% set element_attributes = element_attributes|merge({class: (element_attributes.class|default('') ~ additional_class)}) %} <span{{ knp_menu.attributes(element_attributes) }}> {{ block('label') }} </span>{% endblock %}{% block label %} {% if item.attributes.icon is defined %} <span class="nav-icon mai">{{ item.attributes.icon }}</span> {% endif %} <span class="nav-content"> <span class="nav-text"> {% if options.allow_safe_labels and item.getExtra('safe_label', false) %} {{ item.label|raw }} {% else %} {{ item.label }} {% endif %} </span> {% if item.children|length > 0 %} <span class="mai mai-chevron">expand_more</span> {% else %} <span class="mai mai-arrow">arrow_forward</span> {% endif %} </span>{% endblock %}