Use is_mega_menu from nav_menu component in a menu block

Created on 19 January 2024, 5 months ago
Updated 20 January 2024, 5 months ago

Reported by Thomas from Γ‰duscol STI.

We haven't found how to enable the is_mega_menu boolean as defined in the YAML file:

  settings:
    is_mega_menu:
      label: Is mega menu?
      type: boolean
      description: If true the menu will be displayed as mega menu.
      preview: false

I expected to see these options offered in the management of the Main Navigation block but I must have missed something.

By adding "by hand" {% set is_mega_menu = true %} at the start of the pattern-nav-menu.html.twig file, I obtain the mega menu, which reassures me in the idea that it is possible, knowing that this is not a satisfactory solution.

For your information, we are working on your development version.

πŸ’¬ Support request
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pdureau
  • πŸ‡«πŸ‡·France pdureau Paris
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • πŸ‡«πŸ‡·France pdureau Paris

    Hi Thomas,

    If you are using the "Main Navigation" block from "Block layout" admin page (/admin/structure/block) you are in fact using this "presenter template" : menu--main.html.twig

    {% if items %}
      {{ pattern('nav_menu', {
        'menu_name': menu_name,
        'html_id': 'navigation-main',
        'items': items
      }) }}
    {% endif %}

    So, the settings of the pattern are hardcoded in this file and are not available from backoffice.

    2 proposals

    From backoffice

    Because you are using the development version of ui_suite_dsfr, the menu items are already available as a configurable setting.

    So you can use this little module https://www.drupal.org/project/ui_patterns_pattern_block β†’ to place a block, pick the nav_menu component, and configure it.

    However, as you can see, this module is not actively maintained, and will be rewritten and merged into the upcoming UI Patterns 2.x. So it may be a bit risky to use it.

    From Twig code

    Instead of modifying pattern-nav-menu.html.twig file, you can modify menu--main.html.twig. It is cleaner this way.

    I recommend not doing the change directly in your local ui_suite_dsfr, but in a sub-theme.

  • Status changed to Closed: won't fix 5 months ago
  • πŸ‡«πŸ‡·France pdureau Paris

    I talked with Thomas, it is OK now

Production build 0.69.0 2024