gin-8.x-3.0-alpha22/templates/navigation/menu--toolbar--gin.html.twig

templates/navigation/menu--toolbar--gin.html.twig
{#
/**
 * @file
 * Default theme implementation to display a toolbar 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 %}

{#
  We call a macro which calls itself to render the full tree.
  @see https://twig.symfony.com/doc/1.x/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0, false, menu_name, icon_default, icon_path) }}

{% macro menu_links(items, attributes, menu_level, parent, menu_name, icon_default, icon_path) %}
  {% import _self as menus %}
  {% if items %}
    {% if menu_level == 0  %}
      <ul{{ attributes.addClass('toolbar-menu') }}>
    {% else %}
      <ul class="toolbar-menu">
    {% endif %}
    {% for item in items %}
      {%
        set classes = [
          'menu-item',
          item.is_expanded ? 'menu-item--expanded',
          item.is_collapsed ? 'menu-item--collapsed',
          item.in_active_trail ? 'menu-item--active-trail',
          item.gin_id ? 'menu-item__' ~ item.gin_id
        ]
      %}

      {# {% if menu_name == 'admin' %} #}
        {# Add Home if it doesn't exist #}
        {% if menu_level == 0 and loop.index == 1 and item.gin_id != 'admin_toolbar_tools-help' %}
          <li class="menu-item menu-item--expanded menu-item__tools">
            {% if icon_default == false and icon_path != '' %}
              <a href="/" class="toolbar-logo" data-drupal-link-system-path="<front>">
                <img src="{{ file_url(icon_path) }}" class="toolbar-icon-home" />
              </a>
            {% else %}
              <a href="/" class="toolbar-icon toolbar-icon-admin-toolbar-tools-help toolbar-icon-default" data-drupal-link-system-path="<front>">
                {{ 'Home'|t }}
              </a>
            {% endif %}
          </li>
        {% endif %}

        {% if menu_level == 0 and item.gin_id == 'help-main' %}
          <li class="menu-item menu-item__spacer menu-item--no-link"></li>
        {% endif %}

        {# Add Menu Titles #}
        {% if menu_level == 1 and loop.index == 1 %}
          <li class="menu-item-title">
            <h2 class="toolbar-menu__title">
              <a href="{{ parent.url }}">{{ parent.title }}</a>
            </h2>
          </li>
          <li class="menu-item">
            <a href="{{ parent.url }}" class="toolbar-icon">{{ 'Overview'|t }}</a>
          </li>
        {% elseif menu_level > 1 and loop.index == 1 %}
          <li class="menu-item-title">
            <h3 class="toolbar-menu__sub-title">
              <a href="{{ parent.url }}">{{ parent.title }}</a>
            </h3>
          </li>
          <li class="menu-item">
            <a href="{{ parent.url }}" class="toolbar-icon">{{ 'Overview'|t }}</a>
          </li>
        {% endif %}
      {# {% endif %} #}

      <li{{ item.attributes.addClass(classes) }}>
        {% if item.gin_id == 'admin_toolbar_tools-help' and icon_default == false and icon_path != '' %}
          <a href="/" class="toolbar-logo" data-drupal-link-system-path="<front>">
            <img src="{{ file_url(icon_path) }}" class="toolbar-icon-home" />
          </a>
        {% elseif item.gin_id == 'admin_toolbar_tools-help' %}
          {{ link(item.title, item.url, {'class': ['toolbar-icon-default']}) }}
        {% else %}
          {{ link(item.title, item.url) }}
        {% endif %}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1, item, menu_name) }}
        {% endif %}
      </li>
    {% endfor %}
    </ul>
  {% endif %}

  {% if menu_level == 0 %}
    {# Custom toggle for menu #}
    <a href="#" class="toolbar-menu__trigger trigger" role="button" aria-pressed="false">{{ 'Close'|t }}</a>
  {% endif %}
{% endmacro %}

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

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