Problem/Motivation
A custom theme suggestion added using the add_suggestion Twig filter is not being picked up.
Steps to reproduce
We have the following template overrides in our custom theme:
- menu--extras.html.twig
- menu--extras--main.html.twig
- menu--extras--main--sub.html.twig
In another template, we want to render the main menu. Not with the usual markup (menu--extras--main.html.twig), but with custom markup for that specific use case. We're doing that using the new add_suggestion Twig filter:
{{ main_menu|add_suggestion('sub') }}
The problem is that while the menu--extras--main--sub.html.twig template exists, the menu--extras--main.html.twig template is still used. This happens because menu_item_extras_theme_suggestions_menu_alter adds its suggestions after the --sub suggestion added using add_suggestion.
Proposed resolution
Change menu_item_extras_theme_suggestions_menu_alter to menu_item_extras_theme_suggestions_menu. This way, its templates don't take precendence over absolutely everything, as they shouldn't. I don't see a reason why it should be an alter anyway, since it's only adding suggestions to the list and not changing existing suggestions.
Remaining tasks
Do it.
Issue fork menu_item_extras-3349937
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
Comment #3
dieterholvoet commentedComment #5
podaroktnx
Comment #6
dieterholvoet commentedI think you forgot to merge the MR and to give me credit.
Comment #7
podarokComment #8
podaroknow you have it https://www.drupal.org/u/DieterHolvoet/issue-credits/2895023
this is because you haven't assigned it to you when working on it