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/themes/stable9/templates/navigation/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({'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. <nav class="admin-toolbar__scroll-wrapper" aria-label="{{ 'Administrative sidebar'|t }}">
  46. {% set title_menu = 'admin-toolbar-title'|clean_unique_id %}
  47. {# @todo - We should get rid of this ID below. #}
  48. <div{{ region_attributes.content
  49. .setAttribute('id', 'menu-builder')
  50. .addClass('admin-toolbar__content')
  51. }}>
  52. {# @todo - Needs to be placed here so we can have the header footer on mobile. #}
  53. <div class="admin-toolbar__header">
  54. {% if not settings.hide_logo %}
  55. <a class="admin-toolbar__logo" href="{{ path('<front>') }}">
  56. {% if settings.logo_path is not null %}
  57. <img alt="{{ 'Navigation logo'|t }}" src="{{ settings.logo_path }}" loading="eager" width="{{ settings.logo_width|default(40) }}" height="{{ settings.logo_height|default(40) }}">
  58. {% else %}
  59. {% include '@navigation/logo.svg.twig' with {
  60. label: 'Navigation logo'|t
  61. } only %}
  62. {% endif %}
  63. </a>
  64. {% endif %}
  65. {% include 'navigation:toolbar-button' with {
  66. attributes: create_attribute({ 'data-toolbar-back-control': true, 'tabindex': '-1' }),
  67. extra_classes: ['admin-toolbar__back-button'],
  68. icon: { icon_id: 'arrow-left' },
  69. text: 'Back'|t,
  70. } only %}
  71. {% include 'navigation:toolbar-button' with {
  72. action: 'Collapse sidebar'|t,
  73. attributes: create_attribute({ 'aria-controls': 'admin-toolbar', 'tabindex': '-1', 'type': 'button' }),
  74. extra_classes: ['admin-toolbar__close-button'],
  75. icon: { icon_id: 'cross' },
  76. } only %}
  77. </div>
  78. {{ content.content_top }}
  79. {{ content.content }}
  80. </div>
  81. {% set title_menu_footer = 'admin-toolbar-footer'|clean_unique_id %}
  82. <div{{ region_attributes.footer
  83. .setAttribute('id', 'menu-footer')
  84. .addClass('admin-toolbar__footer')
  85. }}>
  86. {{ content.footer }}
  87. <button aria-controls="admin-toolbar" class="admin-toolbar__expand-button" type="button">
  88. {{ icon('navigation', 'chevron', { class: 'admin-toolbar__expand-button-chevron', size: 16 }) }}
  89. <span class="visually-hidden" data-toolbar-text>{{ 'Collapse sidebar'|t }}</span>
  90. </button>
  91. </div>
  92. </nav>
  93. </aside>
  94. <div class="admin-toolbar-overlay" aria-controls="admin-toolbar" data-drupal-admin-styles></div>
  95. <script>
  96. if (localStorage.getItem('Drupal.navigation.sidebarExpanded') !== 'false' && (window.matchMedia('(min-width: 1024px)').matches)) {
  97. document.documentElement.setAttribute('data-admin-toolbar', 'expanded');
  98. }
  99. </script>

Related topics


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