When using the Zen theme in combination with the Menu Block module, the "edit menu" link displayed when hovering over a menu block can trigger a page not found in certain scenarios.
How to reproduce
- Enable the menu block module and set the theme to Zen.
- Set up a new menu block and set the parent item to "<the menu selected by the page>". Make sure that the menu you select here is made available via Administer > Site configuration > Menu block.
- Put the newly created menu block in a visible region on the page.
- Hover over the menu block and click "edit menu". As the "edit menu" link is pointing to /admin/build/menu-customize/_active, this results in a "page not found".
The Zen theme determines the above link based on the menu_block_{$block->delta}_parent variable, which usually contains the name of the menu to use for the menu block. However, since #540842: Add option to use current page's selected menu, this variable can now contain "_active" (MENU_TREE__CURRENT_PAGE_MENU) to denote the active menu.
Fix
While the actual bug is in the Zen theme, it seems silly to copy/paste the logic to determine the active menu from menu block's code. Attached are 2 patches, one that refactors menu block's menu_build_tree function and isolates this logic into a new function menu_block_get_active_menu, and a second patch that changes Zen's template.block-editing.inc to use this new function.
Change should be backwards compatible, so if someone upgrades Zen but sitll uses an older version of menu_block, the broken "edit menu" link is no longer shown for "_active" menus.
The "menu block" patch should obviously go in a separate issue in the menu block queue, but I wanted to see if this approach is acceptable before adding an issue there.
| Comment | File | Size | Author |
|---|---|---|---|
| zen_active_menu.patch | 1.74 KB | mr.baileys | |
| menu_block_active_menu.patch | 2.94 KB | mr.baileys |
Comments
Comment #1
johnalbinIs it okay if we close this issue? Sorry I ignored it for so long. :-(