navigation.html.twig

Same filename in this branch
  1. main core/themes/stable9/templates/navigation/navigation.html.twig
Same filename and directory in other branches
  1. 10 core/modules/navigation/layouts/navigation.html.twig
  2. 11.x core/modules/navigation/layouts/navigation.html.twig
  3. 11.x core/themes/stable9/templates/navigation/navigation.html.twig

Default theme implementation to display a navigation layout.

Available variables:

  • content: The content for this layout.
  • attributes: HTML attributes for the layout <div>.
  • settings: layout settings. The following are related to the logo:
    • hide_logo: Whether to hide the logo.
    • logo_path: The path to the logo image if logo_managed in navigation.settings configuration has been set.
    • logo_width: The width of the logo image. Available if logo_path points to a valid image file.
    • settings.logo_height: The height of the logo image. Available if logo_path points to a valid image file.
2 theme calls to navigation.html.twig
DemoUmamiHooks::navigationContentTop in core/profiles/demo_umami/src/Hook/DemoUmamiHooks.php
Implements hook_navigation_content_top().
DemoUmamiHooks::navigationContentTop in core/profiles/demo_umami/src/Hook/DemoUmamiHooks.php
Implements hook_navigation_content_top().

File

core/modules/navigation/layouts/navigation.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a navigation layout.
  5. *
  6. * Available variables:
  7. * - content: The content for this layout.
  8. * - attributes: HTML attributes for the layout <div>.
  9. * - settings: layout settings. The following are related to the logo:
  10. * - hide_logo: Whether to hide the logo.
  11. * - logo_path: The path to the logo image if logo_managed
  12. * in navigation.settings configuration has been set.
  13. * - logo_width: The width of the logo image. Available if
  14. * logo_path points to a valid image file.
  15. * - settings.logo_height: The height of the logo image. Available if
  16. * logo_path points to a valid image file.
  17. * @ingroup themeable
  18. */
  19. #}
  20. {% set control_bar_attributes = create_attribute() %}
  21. <div{{ control_bar_attributes
  22. .addClass('admin-toolbar-control-bar')
  23. .setAttribute('data-drupal-admin-styles', '')
  24. }}>
  25. <div class="admin-toolbar-control-bar__content">
  26. {% include 'navigation:toolbar-button' with {
  27. attributes: create_attribute({'data-drupal-selector': 'admin-toolbar-mobile-trigger', 'aria-expanded': 'false', 'aria-controls': 'admin-toolbar', 'type': 'button'}),
  28. icon: { icon_id: 'burger' },
  29. text: 'Expand sidebar'|t,
  30. modifiers: ['small-offset'],
  31. extra_classes: [
  32. 'admin-toolbar-control-bar__burger',
  33. ],
  34. } only %}
  35. </div>
  36. </div>
  37. <aside{{ attributes
  38. .addClass('admin-toolbar')
  39. .setAttribute('id', 'admin-toolbar')
  40. .setAttribute('data-drupal-admin-styles', true)
  41. .setAttribute('role', 'presentation')
  42. }}>
  43. {# This lil' div will get the Drupal.displace() attributes added to it via JS. #}
  44. <div class="admin-toolbar__displace-placeholder"></div>
  45. {% set nav_id = 'admin-toolbar__scroll-wrapper-' ~ random() %}
  46. <nav class="admin-toolbar__scroll-wrapper" aria-labelledby="{{ nav_id }}">
  47. <h2 id="{{ nav_id }}" class="visually-hidden">{{ 'Administrative sidebar'|t }}</h2>
  48. {% set title_menu = 'admin-toolbar-title'|clean_unique_id %}
  49. {# @todo - We should get rid of this ID below. #}
  50. <div{{ region_attributes.content
  51. .setAttribute('id', 'menu-builder')
  52. .addClass('admin-toolbar__content')
  53. }}>
  54. {# @todo - Needs to be placed here so we can have the header footer on mobile. #}
  55. <div class="admin-toolbar__header">
  56. {% if not settings.hide_logo %}
  57. <a class="admin-toolbar__logo" href="{{ path('<front>') }}">
  58. {% if settings.logo_path is not null %}
  59. <img src="{{ file_url(settings.logo_path) }}" loading="eager" width="{{ settings.logo_width|default(40) }}" height="{{ settings.logo_height|default(40) }}" role="presentation" aria-hidden="true" focusable="false">
  60. {% else %}
  61. {% include '@navigation/logo.svg.twig' only %}
  62. {% endif %}
  63. <span class="visually-hidden">{{ 'Home page'|t }}</span>
  64. </a>
  65. {% endif %}
  66. {% include 'navigation:toolbar-button' with {
  67. attributes: create_attribute({ 'data-toolbar-back-control': true, 'tabindex': '-1' }),
  68. extra_classes: ['admin-toolbar__back-button'],
  69. icon: { icon_id: 'arrow-left' },
  70. text: 'Back'|t,
  71. } only %}
  72. {# The close button should be in the tab sequence. Therefore, `tabindex` is omitted here. #}
  73. {% include 'navigation:toolbar-button' with {
  74. action: 'Collapse sidebar'|t,
  75. attributes: create_attribute({ 'aria-controls': 'admin-toolbar', 'type': 'button' }),
  76. extra_classes: ['admin-toolbar__close-button'],
  77. icon: { icon_id: 'cross' },
  78. } only %}
  79. </div>
  80. {{ content.content_top }}
  81. {{ content.content }}
  82. </div>
  83. {% set title_menu_footer = 'admin-toolbar-footer'|clean_unique_id %}
  84. <div{{ region_attributes.footer
  85. .setAttribute('id', 'menu-footer')
  86. .addClass('admin-toolbar__footer')
  87. }}>
  88. {{ content.footer }}
  89. <button aria-controls="admin-toolbar" class="admin-toolbar__expand-button" type="button">
  90. {{ icon('navigation', 'chevron', { class: 'admin-toolbar__expand-button-chevron', size: 16 }) }}
  91. <span class="visually-hidden" data-toolbar-text>{{ 'Collapse sidebar'|t }}</span>
  92. </button>
  93. </div>
  94. </nav>
  95. </aside>
  96. <div class="admin-toolbar-overlay" admin-toolbar-trigger data-drupal-admin-styles></div>
  97. <script>
  98. if (localStorage.getItem('Drupal.navigation.sidebarExpanded') !== 'false' && (window.matchMedia('(min-width: 1024px)').matches)) {
  99. document.documentElement.setAttribute('data-admin-toolbar', 'expanded');
  100. }
  101. </script>

Related topics


Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.