Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
How to replicate:
- Create a new menu with a few sample links (not the pre-installed "main" etc)
- Place the menu block for the menu in your layout and give it a unique machine name.
- Place a second instance of the same menu block in your layout and give it a unique machine name different from the first.
- Turn on and view theming suggestions for each with render cache on and off.
Issues & Notes:
- The theme suggestions for each block should be different due to different assigned machine names but instead it duplicates the first onto the additional instances leaving no way to use a different TWIG template for each menu block.
- When render cache is off we get different suggestions for each block but instead of using the assigned machine name it appends the first instance machine name with
--2
etc for the additional instances. - Again note this isn't an issue with the already provided
main
menu. Just multiple instances of menu blocks for a new menu.
Comments
Comment #2
Soundvessel CreditAttribution: Soundvessel commentedIssues
4. There is also a case where main menu block will not respect it's machine name if the block is disabled but supplied to a page template e.g.
$variables['content_row_menu_blocks'] = entity_load('block', 'mainnavigation_content_rows')->getPlugin()->build();
Comment #8
quietone CreditAttribution: quietone at PreviousNext commentedI tested this on Drupal 9.5.x, standard install and was able to reproduce the problem. I don't usually do anything with twig but I didn't have issues testing this. I made a menu block and placed the first instance in the footer and the second in the header. Here are the results without and with caching.
Caching off
First time place block 'newtest'
Place another instance of 'newtest' in a different region. There are some suggestions that still show 'newtest' and not 'newtest-2'.
Cache enabled and the results are the same.
Place another instance of 'newtest' in a different region. There are some suggestions that still show 'newtest' and not 'newtest-2'.