I have a single menu split into menu blocks like this Menu Level 1+, Menu Level 2+, Menu Level 3+. The first level is used as my site's main navigation menu at the top of the page, the second menu block appears in the content (within a panel) showing the children of level 1's active item as a secondary navigation. The 3rd level menu block appears in a panel node showing the children of level 2's active item.
The problem is that level 1 and level 2 menu blocks are showing correctly however level 3 does not. It seems that the active trail stops at the second level menu block and i'm wondering if this is a problem with panels or something i've done wrong.
Comments
Comment #1
JohnAlbinComment #2
lmeurs CreditAttribution: lmeurs commentedI sort of am experiencing the same. Menu item trails in menu blocks inside a Panels pane do not always have
.active
and.active-trail
classes, though menu items in the same menu block inside a standard Drupal region do.I use Ctools Page Manager + Panels to override
taxonomy/term/%
pages. A menu built by Taxonomy Menu with product categories is displayed inside a Panel pane on the left and also in a standard Drupal footer region. The same setup is used to display product node pages.When visiting a Product Category taxonomy term page, all menu items are activated as expected. To set an active menu trail for nodes so their corresponding product category menu items are activated, I used something like:
This does work for menu blocks in default Drupal regions, but not for menu blocks inside Panel panes. This probably has to do with the pane being rendered before the blocks and before the
hook_preprocess_page()
implementation which sets the active menu trail. After trying many other hooks, there seem two workarounds:hook_menu_block_tree_alter()
which is called whenever a menu block is being generated. This implementation sets the active menu trail and calls Menu Block'smenu_tree_add_active_path()
to activate the right menu items.hook_init()
, but this would also be called on pages that do not contain any menu block.Comment #3
capysara CreditAttribution: capysara commented#2 hook_menu_block_tree_alter worked for me. Thanks!