templates/menu/main-template.html.twig line 1
{% extends "@KnpMenu/menu.html.twig" %}
{% import 'knp_menu.html.twig' as knp_menu %}
{% block list %}
{# {{ dump(item,matcher) }} #}
{% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %}
{# {% import _self as knp_menu %} #}
<nav class="section-navigation">
<div class="section-navigation__inner container">
{{ block('children_desktop') }}
{{ block('children_mobile') }}
</div>
</nav>
{% set selectedMenu = null %}
{% for it in item.children %}
{%- if matcher.isCurrent(it) or matcher.isAncestor(it, options.matchingDepth) %}
{% if it.children|length %}
{% set selectedMenu=it %}
{% endif %}
{% endif %}
{% endfor %}
{% if selectedMenu %}
{{ block('second_level') }}
{% endif %}
{% endif %}
{% endblock %}
{% block second_level %}
<nav class="secondary-section-navigation">
<ul class="secondary-section-navigation__nav container">
{% for item in selectedMenu %}
<li class="secondary-section-navigation__nav-link
{% if matcher.isCurrent(item) or matcher.isAncestor(item, options.matchingDepth) %}
secondary-section-navigation__nav-link_active
{% endif %}
">
{{ block("linkElement") }}
</li>
{% endfor %}
</ul>
</nav>
{% endblock %}
{% block children_desktop %}
{# 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 %}
{% set selectedMenu=null %}
<ul class="section-navigation__nav">
{% for item in currentItem.children %}
{%- if matcher.isCurrent(item) or matcher.isAncestor(item, options.matchingDepth) %}
{% set selectedMenu=item %}
{% endif %}
{{ block('item_desktop') }}
{% endfor %}
</ul>
{# {% if selectedMenu and selectedMenu.children|length %}
<ul class="section-navigation__nav section-navigation__submenu ">
#}{# {{ dump(selectedMenu) }} #}{#
{% for item in selectedMenu.children %}
{{ block('item_desktop') }}
{% endfor %}
</ul>
{% endif %}
#}
{# restore current variables #}
{% set item = currentItem %}
{% set options = currentOptions %}
{% endblock %}
{% block children_mobile %}
{# 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 %}
{# <div class="section-navigation__mobile-nav">
<div class="section-navigation__mobile-nav-title">Об учебном заведении</div>
<a class="section-navigation__mobile-nav-button" data-toggle="collapse"
data-target=".section-navigation__mobile-nav-menu">
<i class="far fa-bars"></i></a>
</div>
<div class="section-navigation__mobile-nav-menu collapse">
<ul>
<li class="section-navigation__mobile-nav-link"><a href="/">Олимпиады</a></li>
<li class="section-navigation__mobile-nav-link"><a href="/">Новости</a></li>
<li class="section-navigation__mobile-nav-link"><a href="/">События</a></li>
<li class="section-navigation__mobile-nav-link"><a href="/">Контакты</a></li>
</ul>
</div> #}
{% for item in currentItem.children|filter(item => matcher.isCurrent(item) or matcher.isAncestor(item, options.matchingDepth) ) %}
{{ block('item_mobile_current') }}
{% endfor %}
{% set otherElements =currentItem.children|filter(item => false == matcher.isCurrent(item) and false == matcher.isAncestor(item, options.matchingDepth)) %}
{% if otherElements|length %}
<div class="section-navigation__mobile-nav-menu collapse">
<ul>
{% for item in otherElements %}
{{ block('item_mobile_other') }}
{% endfor %}
</ul>
</div>
{% endif %}
{# restore current variables #}
{% set item = currentItem %}
{% set options = currentOptions %}
{% endblock %}
{% block item_mobile_current %}
<div class="section-navigation__mobile-nav">
<div class="section-navigation__mobile-nav-title">{{ block('simpleLinkElement') }}</div>
<a class="section-navigation__mobile-nav-button" data-toggle="collapse"
data-target=".section-navigation__mobile-nav-menu">
<i class="far fa-bars"></i></a>
</div>
{% endblock %}
{% block item_mobile_other %}
{%- set classes = item.attribute('class') is not empty ? [item.attribute('class')] : [] %}
{%- set classes = classes|merge(["section-navigation__mobile-nav-link",options.itemMobileClass|default]) %}
{%- set attributes = item.attributes %}
{%- if classes is not empty %}
{%- set attributes = attributes|merge({'class': classes|join(' ')}) %}
{%- endif %}
<li{{ knp_menu.attributes(attributes) }}>
{# {%- if item.uri is not empty and (not matcher.isCurrent(item) or options.currentAsLink) %}
{{ block('linkElement') }}
{%- else %} #}
{{ block('linkElement') }}
{# {%- endif %} #}
</li>
{# <li class="section-navigation__mobile-nav-link"><a href="/">Контакты</a></li> #}
{% endblock %}
{% block item_desktop %}
{# {{ dump(knp_menu) }} #}
{% if item.displayed %}
{# building the class of the item #}
{%- set classes = item.attribute('class') is not empty ? [item.attribute('class')] : [] %}
{%- set classes = classes|merge(["section-navigation__nav-link",options.itemDesktopClass|default]) %}
{%- 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 %}
{% if item.hasChildren %}
{%- set classes = classes|merge(["submenu"]) %}
{% 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 %} #}
<li{{ knp_menu.attributes(attributes) }}>
{# {%- if item.uri is not empty and (not matcher.isCurrent(item) or options.currentAsLink) %}
{{ block('linkElement') }}
{%- else %} #}
{{ block('linkElement') }}
{# {%- endif %} #}
</li>
{% endif %}
{% endblock %}
{% block label %}{% if options.allow_safe_labels and item.getExtra('safe_label', false) %}{{ item.label|raw }}{% else %}{{ item.label|trans }}{% endif %}{% endblock %}
{% block linkElement -%}
{%- set classes = item.linkAttributes('class') is not empty ? [item.linkAttributes('class')] : [] %}
{%- if matcher.isCurrent(item) %}
{%- set classes = classes|merge([options.currentClass]) %}
{%- elseif matcher.isAncestor(item, options.matchingDepth) %}
{%- set classes = classes|merge([options.ancestorClass]) %}
{%- endif %}
{%- set attributes = item.linkAttributes %}
{%- if classes is not empty %}
{%- set attributes = attributes|merge({'class': classes|join(' ')}) %}
{%- endif %}
<a href="{{ item.uri|default("#") }}"{{ knp_menu.attributes(attributes) }}>{{ block('label') }}</a>
{%- endblock %}
{% block simpleLinkElement -%}
<a href="{{ item.uri|default("#") }}">{{ block('label') }}</a>
{%- endblock %}