Hello, by enable the module, it add me the suggestion "menu--[id of the menu].html.twig" on the top of the list of suggestions.

Without the module:

<!-- FILE NAME SUGGESTIONS:
   x menu--footer-test.html.twig
   * menu--footer.html.twig
   * menu.html.twig
-->

and with "Menu Item Extras"

<!-- FILE NAME SUGGESTIONS:
   x menu--footer.html.twig
   * menu--footer-test.html.twig
   x menu--footer.html.twig
   * menu.html.twig
-->

and, "menu--footer.html.twig" is used instead of "menu--footer-test.html.twig"...

To make it works in me case, I need to comment the folling line in file "menu_item_extras.module":

    // We have to add back the original suggestion that normally is generated
    // from the #theme, because in pre-process we are replacing it with 'menu'.
    //$suggestions[] = $utility::suggestion('menu', $menu_name);

Why?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

steveoriol created an issue. See original summary.

kobb’s picture

I also had to comment out this line. The module overrides the block "Theme hook suggestion".

mbopp’s picture

StatusFileSize
new696 bytes

Patch for change.

Petr Illek made their first commit to this issue’s fork.

petr illek’s picture

Status: Active » Needs review

Hi,
I've run in same issues.
The patch #3 works, but commenting out the code, does not feel as the approach I would like to go. It may break some other logic elsewhere in the module we are not aware of.

Instead of this we used a different approach with checking the final suggestion array for duplicates and leave only unique content (thanks for the help to @cferthorney). See the fork.

dave reid’s picture

Version: 8.x-2.8 » 8.x-2.x-dev
Status: Needs review » Needs work

We're seeing this as well. The suggestion order doesn't seem correct. The more generic menu--extras.html.twig suggestion is getting put in higher order above menu--MENU-NAME, which is not what we want. I think the order should be the following:

- menu--extras--MENU-NAME
- menu--MENU-NAME
- menu--extras
- menu

ozin’s picture

Status: Needs work » Postponed (maintainer needs more info)

Hi all!
I can't reproduce this issue.
I'm using Olivero 9.1.3 as a default theme and I get these suggestions:

<!-- FILE NAME SUGGESTIONS:
   x menu--primary-menu.html.twig
   * menu--extras--main--primary-menu.html.twig
   * menu--extras--main.html.twig
   * menu--extras.html.twig
   * menu--main.html.twig
   * menu.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/olivero/templates/navigation/menu--primary-menu.html.twig' -->

Could you provide more details which theme do you use and what is your base theme?

dave reid’s picture

Can you try with the Classy or Stable themes? We're also using a manually rendered menu, not using a block, that may be part of it since we don't see the additional suggestions that include the region.

Also, menu--primary-menu.html.twig seems like an odd suggestion. Shouldn't it be menu--main--primary-menu.html.twig?

joelseguin’s picture

I've come accross a relevant issue when I just recently updated to version 2.14 (from 2.13). My template overrides were broken after the upgrade as naming suggestions changed. I couldn't seem to be able to override as expected anymore and therefore have since reverted back to 2.13.

Here is what I used to get in 2.13:

I'm now getting the following in 2.14:

Note that I have three menus in the examples above (one of which was for testing purposes): menu_main, menu_main_off_canvas and menu_main_off_canvas_v2.

ozin’s picture

Assigned: Unassigned » ozin
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.1 KB

  • ozin committed 5ea2046 on 3092021-double-suggestion
    Resolves #3092021 by Petr Illek, ozin, mbopp: double suggestions
    
ozin’s picture

Hi @joelseguin,
Please check if the latest version 2.15 works for you?

joelseguin’s picture

Hi @ozin,

Just tested out 2.15 and all is working as expected. The template suggestions are the same as with 2.13 so no broken templates.

Thanks!

steveoriol’s picture

Status: Needs review » Reviewed & tested by the community

Well done @ozin, I can confirm that the patch is working really well!
Thank you :-)

  • ozin committed db5252c on 8.x-2.x
    Resolves #3092021 by Petr Illek, ozin, mbopp: double suggestions
    
ozin’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.