{% extends 'knp_menu_base.html.twig' %}{% set currentClass = options.currentClass ?? 'active' %}{% macro attributes(attributes) %} {% for name, value in attributes %} {%- if value is not none and value is not same as(false) -%} {{- ' %s="%s"'|format(name, value is same as(true) ? name|e : value|e)|raw -}} {%- endif -%} {%- endfor -%}{% endmacro %}{% block compressed_root %} {% apply spaceless %} {{ block('root') }} {% endapply %}{% endblock %}{% block root %} {% set listAttributes = item.childrenAttributes %} {{ block('list') -}}{% endblock %}{# list renders listing of menu object #}{% block list %} {% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %} {{ block('children') }} {% endif %}{% endblock %}{# children renders childrens of object #}{% block children %} {# save current variables #} {% set currentOptions = options %} {% set currentItem = item %} {# update the depth for children #} {% if options.depth is not none %} {% set options = options|merge({'depth': currentOptions.depth - 1}) %} {% endif %} {# update the matchingDepth for children #} {% if options.matchingDepth is not none and options.matchingDepth > 0 %} {% set options = options|merge({'matchingDepth': currentOptions.matchingDepth - 1}) %} {% endif %} {% for item in currentItem.children %} {{ block('item') }} {% endfor %} {# restore current variables #} {% set item = currentItem %} {% set options = currentOptions %}{% endblock %}{# item renders object of elements #}{% block item %} {% if item.displayed and item.attributes.enabled %} {# 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([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 %} {# 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 %} {%- if item.uri is not empty and (not matcher.isCurrent(item) or options.currentAsLink) %} {{ block('linkElement') }} {%- elseif 'section' == item.attributes.menuType %} {{ block('sectionElement') }} {%- else %} {{ block('spanElement') }} {%- endif %} {# render the list of children #} {%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %} {%- set childrenClasses = childrenClasses|merge(['menu_level_' ~ item.level]) %} {%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' ') }) %} {{ block('list') }} {% endif %}{% endblock %}{# LinksElements Shows Elements with no childrens #}{% block linkElement %} {% import _self as knp_menu %} {%- set classes = item.linkAttribute('class') is not empty ? [item.linkAttribute('class')] : [] %} {%- if matcher.isCurrent(item) %} {%- set classes = classes|merge([currentClass]) %} {%- endif %} {%- set attributes = item.linkAttributes %} {%- if classes is not empty %} {%- set attributes = attributes|merge({'class': classes|join(' ')}) %} {%- endif %} {% if item.level < 2 %} <div class="menu-item"> <a {{ knp_menu.attributes(attributes) }} href="{{ item.uri }}"> <span class="menu-icon"> {% if item.attribute('icon') is not empty %} <span class="svg-icon svg-icon-2"> <i class="{{ item.attribute('icon') }}"></i> </span> {% endif %} </span> <span class="menu-title">{{ block('label')}}</span> </a> </div> {% endif %}{% endblock %}{# spanElement Shows Elements with childrens #}{% block spanElement %} {% import _self as knp_menu %} {% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %} {% import _self as knp_menu %} {%- set classes = item.linkAttribute('class') is not empty ? [item.linkAttribute('class')] : [] %} {%- if matcher.isCurrent(item) %} {%- set classes = classes|merge([currentClass]) %} {%- endif %} {%- set attributes = item.linkAttributes %} {%- if classes is not empty %} {%- set attributes = attributes|merge({'class': classes|join(' ')}) %} {%- endif %} {% set subItemUri = [] %} {% for subItem in item.children %} {% set subItemUri = subItemUri|merge([subItem.uri]) %} {% endfor %} <div data-kt-menu-trigger="click" class="menu-item menu-accordion {% if item.current %}hover show{% elseif app.request.pathinfo in subItemUri %}hover show{% endif %}"> <span class="menu-link"> <span class="menu-icon"> {% if item.attribute('icon') is not empty %} <span class="svg-icon svg-icon-2"> <i class="{{ item.attribute('icon') }}"></i> </span> {% endif %} </span> <span class="menu-title">{{ block('label') }}</span> <span class="menu-arrow"></span> </span> <div class="menu-sub menu-sub-accordion {% if item.current %}hover show{% elseif app.request.pathinfo in subItemUri %}hover show{% endif %}"> {% for subItem in item.children %} {% if subItem.displayChildren and subItem.attributes.enabled %} <div class="menu-item"> <a class="menu-link {{subItem.attributes.class}} {% if subItem.uri == app.request.pathinfo %}active{% endif %}" href="{{ subItem.uri }}"> <span class="menu-icon"> {% if subItem.attribute('icon') is not empty %} <span class="svg-icon svg-icon-2"> <i class="{{ subItem.attribute('icon') }}"></i> </span> {% endif %} </span> <span class="menu-title">{{ subItem.label }}</span> </a> </div> {% endif %} {% endfor %} </div> </div> {% endif %}{% endblock %}{# section renders sections of elements #}{% block sectionElement %} <div class="menu-item pt-5"> <div class="menu-content"> <span class="menu-heading fw-bold text-uppercase fs-7">{{ block('label')}}</span> </div> </div>{% endblock %}{# label renders labels of elements #}{% block label %} {# {% if options.allow_safe_labels and item.getExtra('safe_label', false) %} #} {{ item.label|raw }} {# {% else %} {{ item.label }} {% endif %} #}{% endblock %}