bootstrap_cloud-2.x-dev/templates/menu/menu--main.html.twig
templates/menu/menu--main.html.twig
{#
/**
* @file
* Default theme implementation to display a menu.
*
* Available variables:
* - classes: A list of classes to apply to the top level <ul> element.
* - dropdown_classes: A list of classes to apply to the dropdown <ul> element.
* - 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.
*
* @ingroup templates
*/
#}
{# {% extends "menu.html.twig" %}
{%
set classes = [
'menu',
'menu--' ~ menu_name|clean_class,
'nav',
'navbar-nav',
]
%} #}
{% import _self as menus %}
{#
Re-enable tertiary navigation. Based on the blog post:
http://demo.jdmdigital.co/wp-bootstrap-navwalker-multilevel/
#}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
<ul class="nav navbar-nav" role="menu">
{% else %}
<ul class="dropdown-menu" role="menu">
{% endif %}
{% for item in items %}
{% if item.below %}
{% if menu_level == 0 %}
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">{{ item.title }} <span class="caret"></span></a>
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
</li>
{% else %}
<li class="dropdown-submenu">
<a href="{{ item.url }}" class="dropdown-submenu-toggle dropdown-toggle" data-toggle="dropdown">{{ item.title }} <span class="caret"></span></a>
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
</li>
{% endif %}
{% else %}
<li {{ item.attributes }}>{{ link(item.title, item.url) }}</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
</ul>
