The simplify_menu module allows you to access and customize Drupal menu structures directly within your Twig templates. This provides full control over the menu's render array, enabling easier markup customization for accessibility and standards compliance.
The simplify_menu module uses a TwigExtension to gain access to Drupal's main menu's (or any other menu for that matter), render array so it can be accessed from a twig template. Among the many advantages of having full control of the menu's render array in a twig template is the ability to customize the markup for your menus to ensure they are accessible and comply with standards.
How to use
{# Get menu items #}
{% set items = simplify_menu('main') %}
{# Iterate menu tree #}
<nav class="navigation__items">
{% for menu_item in items.menu_tree %}
<li class="navigation__item">
<a href="{{ menu_item.url }}">{{ menu_item.text }}</a>
</li>
{% endfor %}
</nav>
Blog post
Read a detailed blog post by Tim Dickens of Mediacurrent.
https://www.mediacurrent.com/blog/simplify-menu-and-twig-macros
Ask your assistant about Simplify Menu
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.