Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There are 2 menu templates that we can rationalise in the Umami theme:
menu--main.html.twig is almost identical to menu.html.twig
If we set line 49 of menu.html.twig in a twig block {% block selector %}
, then we can use {% extends ... %} for the menu--main.html.twig file and use the {% block selector %}
to set what we need.
I think the other templates should remain as they are.
core/themes/umami/templates/components/navigation/menu--main.html.twig
core/themes/umami/templates/components/navigation/menu.html.twig
Comments
Comment #3
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedComment #5
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedComment #6
mradcliffeIt is a little unclear to me about the expected resolution, @markconroy.
I think that the goal is to reduce duplicate code in
core/themes/umami/templates/components/navigation/menu--main.html.twig
by making use of Twig extended syntax. And then this would require using the block selector twig syntax to implement the overrides.Comment #7
melinda_ksz CreditAttribution: melinda_ksz at 1xINTERNET commentedMikael and me are starting to work on this issue at Drupal Europe sprint.
Comment #8
holist CreditAttribution: holist at Siili Solutions commentedI am mentoring Melinda and Mikael on this.
Comment #9
mikael_ek CreditAttribution: mikael_ek commentedWe tried doing the extend/block solution, but the block would not be replaced when placed inside the macro.
Comment #10
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedThere was a lot of work done in this today and the conclusion was that we don't think it's possible at the moment.
Marking as closed.