block--system-menu-block.html.twig

Same filename in this branch
  1. 8.9.x core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig
  2. 8.9.x core/themes/seven/templates/classy/block/block--system-menu-block.html.twig
  3. 8.9.x core/themes/claro/templates/classy/block/block--system-menu-block.html.twig
  4. 8.9.x core/themes/stable/templates/block/block--system-menu-block.html.twig
  5. 8.9.x core/themes/classy/templates/block/block--system-menu-block.html.twig
  6. 8.9.x core/modules/system/templates/block--system-menu-block.html.twig
Same filename in other branches
  1. 9 core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig
  2. 9 core/themes/olivero/templates/block/block--system-menu-block.html.twig
  3. 9 core/themes/stable9/templates/block/block--system-menu-block.html.twig
  4. 9 core/themes/seven/templates/classy/block/block--system-menu-block.html.twig
  5. 9 core/themes/claro/templates/classy/block/block--system-menu-block.html.twig
  6. 9 core/themes/bartik/templates/block--system-menu-block.html.twig
  7. 9 core/themes/stable/templates/block/block--system-menu-block.html.twig
  8. 9 core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig
  9. 9 core/themes/classy/templates/block/block--system-menu-block.html.twig
  10. 9 core/modules/system/templates/block--system-menu-block.html.twig
  11. 10 core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig
  12. 10 core/themes/olivero/templates/block/block--system-menu-block.html.twig
  13. 10 core/themes/stable9/templates/block/block--system-menu-block.html.twig
  14. 10 core/themes/claro/templates/classy/block/block--system-menu-block.html.twig
  15. 10 core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig
  16. 10 core/modules/system/templates/block--system-menu-block.html.twig
  17. 11.x core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig
  18. 11.x core/themes/olivero/templates/block/block--system-menu-block.html.twig
  19. 11.x core/themes/stable9/templates/block/block--system-menu-block.html.twig
  20. 11.x core/themes/claro/templates/classy/block/block--system-menu-block.html.twig
  21. 11.x core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig
  22. 11.x core/modules/system/templates/block--system-menu-block.html.twig

Bartik's theme implementation for a menu block.

Available variables:

  • plugin_id: The ID of the block implementation.
  • label: The configured label of the block if visible.
  • configuration: A list of the block's configuration values.
    • label: The configured label for the block.
    • label_display: The display settings for the label.
    • provider: The module or other provider that provided this block plugin.
    • Block plugin specific settings will also be stored here.
  • content: The content of this block.
  • attributes: HTML attributes for the containing element.
    • id: A valid HTML ID and guaranteed unique.
  • title_attributes: HTML attributes for the title element.
  • content_attributes: HTML attributes for the content element.
  • title_prefix: Additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • title_suffix: Additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

Headings should be used on navigation menus that consistently appear on multiple pages. When this menu block's label is configured to not be displayed, it is automatically made invisible using the 'visually-hidden' CSS class, which still keeps it visible for screen-readers and assistive technology. Headings allow screen-reader and keyboard only users to navigate to or skip the links. See http://juicystudio.com/article/screen-readers-display-none.php and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.

File

core/themes/bartik/templates/block--system-menu-block.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Bartik's theme implementation for a menu block.
  5. *
  6. * Available variables:
  7. * - plugin_id: The ID of the block implementation.
  8. * - label: The configured label of the block if visible.
  9. * - configuration: A list of the block's configuration values.
  10. * - label: The configured label for the block.
  11. * - label_display: The display settings for the label.
  12. * - provider: The module or other provider that provided this block plugin.
  13. * - Block plugin specific settings will also be stored here.
  14. * - content: The content of this block.
  15. * - attributes: HTML attributes for the containing element.
  16. * - id: A valid HTML ID and guaranteed unique.
  17. * - title_attributes: HTML attributes for the title element.
  18. * - content_attributes: HTML attributes for the content element.
  19. * - title_prefix: Additional output populated by modules, intended to be
  20. * displayed in front of the main title tag that appears in the template.
  21. * - title_suffix: Additional output populated by modules, intended to be
  22. * displayed after the main title tag that appears in the template.
  23. *
  24. * Headings should be used on navigation menus that consistently appear on
  25. * multiple pages. When this menu block's label is configured to not be
  26. * displayed, it is automatically made invisible using the 'visually-hidden' CSS
  27. * class, which still keeps it visible for screen-readers and assistive
  28. * technology. Headings allow screen-reader and keyboard only users to navigate
  29. * to or skip the links.
  30. * See http://juicystudio.com/article/screen-readers-display-none.php and
  31. * http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
  32. */
  33. #}
  34. {%
  35. set classes = [
  36. 'block',
  37. 'block-menu',
  38. 'navigation',
  39. 'menu--' ~ derivative_plugin_id|clean_class,
  40. ]
  41. %}
  42. {% set heading_id = attributes.id ~ '-menu'|clean_id %}
  43. {% set show_anchor = "show-" ~ attributes.id|clean_id %}
  44. {% set hide_anchor = "hide-" ~ attributes.id|clean_id %}
  45. <nav role="navigation" aria-labelledby="{{ heading_id }}"{{ attributes.addClass(classes)|without('role', 'aria-labelledby') }}>
  46. {# Label. If not displayed, we still provide it for screen readers. #}
  47. {% if not configuration.label_display %}
  48. {% set title_attributes = title_attributes.addClass('visually-hidden') %}
  49. {% endif %}
  50. {{ title_prefix }}
  51. <h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>
  52. {{ title_suffix }}
  53. {# Menu. #}
  54. {% block content %}
  55. <div{{ content_attributes.addClass('content') }}>
  56. {# When rendering a menu without label, render a menu toggle. #}
  57. <div class="menu-toggle-target menu-toggle-target-show" id="{{ show_anchor }}"></div>
  58. <div class="menu-toggle-target" id="{{ hide_anchor }}"></div>
  59. <a class="menu-toggle" href="#{{ show_anchor }}">{% trans %} Show &mdash; {{ configuration.label }}{% endtrans %}</a>
  60. <a class="menu-toggle menu-toggle--hide" href="#{{ hide_anchor }}">{% trans %} Hide &mdash; {{ configuration.label }}{% endtrans %}</a>
  61. {{ content }}
  62. </div>
  63. {% endblock %}
  64. </nav>

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