xbase-2.x-dev/templates/overridden/menu.html.twig

templates/overridden/menu.html.twig
{#
/**
 * @file
 * Default theme implementation to display a menu.
 *
 * Available variables:
 * - menu_name: The machine name of the menu.
 * - items: A nested list of menu items. Each menu item contains:
 *   - attributes: HTML attributes for the menu item.
 *   - below: The menu item child items.
 *   - title: The menu link title.
 *   - url: The menu link url, instance of \Drupal\Core\Url
 *   - localized_options: Menu link localized options.
 *   - is_expanded: TRUE if the link has visible children within the current
 *     menu tree.
 *   - is_collapsed: TRUE if the link has children within the current menu tree
 *     that are not currently visible.
 *   - in_active_trail: TRUE if the link is in the active trail.
 *
 * @ingroup themeable
 */
#}
{% import _self as menus %}

{% macro menu_tree(items, menu_level = 1) %}
  {% import _self as menus %}
  {% set menu_classes = ['menu', 'menu-l' ~ menu_level, menu_level > 1 ? 'menu--submenu'] %}

  <ul{{ create_attribute({'class': menu_classes}) }}>
    {% for item in items %}
      <li{{ item.attributes }}>
        {{ link(item.title, item.url, {'class': ['menu__link', 'menu-l' ~ menu_level ~ '__link']}) }}

        {% if item.is_expanded %}
          <span class="menu__item-toggle"></span>
        {% endif %}

        {% if item.below %}
          {{ menus.menu_tree(item.below, menu_level + 1) }}
        {% endif %}

        {% if item.below_text %}
          <div class="menu__item-below menu-l{{ menu_level }}__item-below">
            {{ item.below_text }}
          </div>
        {% endif %}
      </li>
    {% endfor %}
  </ul>
{% endmacro %}

{% if items %}
  <nav{{ attributes }}>
    {{ menus.menu_tree(items) }}
  </nav>
{% endif %}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc