templates/management/menu/navbar.html.twig line 1

  1. {% extends 'util/knp_menu.html.twig' %}
  2. {% block list %}
  3.     {% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %}
  4.         <ul class="navbar-nav">
  5.             {{ block('children') }}
  6.         </ul>
  7.     {% endif %}
  8. {% endblock %}
  9. {% block item %}
  10.     {% if item.displayed %}
  11.         {% if options.depth <= 2 %}
  12.             <li class="nav-item {{ item.hasChildren ? 'dropdown' : '' }}">
  13.                 {{ block('linkElement') }}
  14.             </li>
  15.         {% else %}
  16.             {{ block('linkElement') }}
  17.         {% endif %}
  18.     {% endif %}
  19. {% endblock %}
  20. {% block children %}
  21.     {# save current variables #}
  22.     {% set currentOptions = options %}
  23.     {% set currentItem = item %}
  24.     {# update the depth for children #}
  25.     {% if options.depth is not none %}
  26.         {% set options = options|merge({'depth': currentOptions.depth + 1}) %}
  27.     {% endif %}
  28.     {% for item in currentItem.children %}
  29.         {{ block('item') }}
  30.     {% endfor %}
  31.     {# restore current variables #}
  32.     {% set item = currentItem %}
  33.     {% set options = currentOptions %}
  34. {% endblock %}
  35. {% block linkElement %}
  36.     {% import _self as knp_menu %}
  37.     {% if options.depth <= 2 %}
  38.         {% if item.hasChildren %}
  39.             {% set active = false %}
  40.             {% for child in item.children %}
  41.                 {% if matcher.isCurrent(child) %}
  42.                     {% set active = true %}
  43.                 {% endif %}
  44.             {% endfor %}
  45.             <a href="{{ item.uri ?? '#' }}"
  46.                class="nav-link {{ item.hasChildren ? 'dropdown-toggle' : '' }} {{ active ? 'active' : '' }}"
  47.                data-bs-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
  48.                 {{ block('label') }}
  49.             </a>
  50.         {% else %}
  51.             <a href="{{ item.uri ?? '#' }}" class="nav-link {% if matcher.isCurrent(item) %}active{% endif %} text-nowrap">
  52.                 {{ block('label') }}
  53.             </a>
  54.         {% endif %}
  55.     {% else %}
  56.         <a href="{{ item.uri ?? '#' }}"
  57.            class="dropdown-item {% if matcher.isCurrent(item) %}active{% endif %}">
  58.             {{ block('label') }}
  59.         </a>
  60.     {% endif %}
  61.     {% if item.hasChildren %}
  62.         <ul class="dropdown-menu">
  63.             {{ block('children') }}
  64.         </ul>
  65.     {% endif %}
  66. {% endblock %}
  67. {% block label %}
  68.     {% if item.getExtra('icon') %}
  69.         <i class="{{ item.getExtra('icon') }}"></i>
  70.     {% endif %}
  71.     {{ parent() }}
  72. {% endblock %}