You are here

menu--simple-mobile-menu.html.twig in Simple Mobile Menu 8.2

Same filename and directory in other branches
  1. 8 templates/menu--simple-mobile-menu.html.twig

Default theme implementation to display a simple_mobile-menu 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.

File

templates/menu--simple-mobile-menu.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a simple_mobile-menu menu.
  5. *
  6. * Available variables:
  7. * - menu_name: The machine name of the menu.
  8. * - items: A nested list of menu items. Each menu item contains:
  9. * - attributes: HTML attributes for the menu item.
  10. * - below: The menu item child items.
  11. * - title: The menu link title.
  12. * - url: The menu link url, instance of \Drupal\Core\Url
  13. * - localized_options: Menu link localized options.
  14. * - is_expanded: TRUE if the link has visible children within the current
  15. * menu tree.
  16. * - is_collapsed: TRUE if the link has children within the current menu tree
  17. * that are not currently visible.
  18. * - in_active_trail: TRUE if the link is in the active trail.
  19. *
  20. * @ingroup themeable
  21. */
  22. #}
  23. {% import _self as menus %}
  24. {#
  25. We call a macro which calls itself to render the full tree.
  26. @see http://twig.sensiolabs.org/doc/tags/macro.html
  27. #}
  28. {{ menus.menu_links(items, attributes, 0) }}
  29. {% macro menu_links(items, attributes, menu_level) %}
  30. {% import _self as menus %}
  31. {% if items %}
  32. {% if menu_level == 0 %}
  33. <ul{{ attributes.addClass('main-mobile-menu') }}>
  34. {% else %}
  35. <ul class="submenu">
  36. {% endif %}
  37. {% for item in items %}
  38. {% set menu_attributes = menus_attribute(items|keys[loop.index0]) %}
  39. {%
  40. set classes = [
  41. 'menu-item',
  42. item.is_expanded ? 'menu-item--expanded',
  43. item.is_collapsed ? 'menu-item--collapsed',
  44. item.in_active_trail ? 'menu-item--active-trail',
  45. menu_attributes.item.class ? menu_attributes.item.class
  46. ]
  47. %}
  48. <li{{ item.attributes.addClass(classes) }}
  49. {% if menu_attributes.item.id %}
  50. {{ item.attributes.setAttribute('id', menu_attributes.item.id) }}
  51. {% endif %}
  52. {% if menu_attributes.item.style %}
  53. {{ item.attributes.setAttribute('style', menu_attributes.item.style) }}
  54. {% endif %} >
  55. {{ link(item.title, item.url, menu_attributes.link) }}
  56. {% if item.below %}
  57. {%
  58. set classes = [
  59. 'sub-menu-item',
  60. item.in_active_trail ? 'menu-item--active-trail',
  61. menu_attributes.item.class ? menu_attributes.item.class
  62. ]
  63. %}
  64. {{ menus.menu_links(item.below, attributes.addClass(classes), menu_level + 1) }}
  65. {% endif %}
  66. </li>
  67. {% endfor %}
  68. </ul>
  69. {% endif %}
  70. {% endmacro %}