In menu_tree_build(), the "current page" is determined by a simple query to {menu_links} based on $_GET['q']
In most cases, this is fine, because if the current page is part of the menu system, then $_GET['q'] will be one and same with the active menu item returned by menu_get_active_trail(). However in some cases, e.g. when menu_set_active_trail() is invoked to change the active trail for a given page, $_GET['q'] doesn't match the active trail.
The attached patch updates menu_tree_build() to use the active trail instead of $_GET['q'].
Maybe this should be a configuration option?
I'm not sure.
Anyway, the patch works for what I need it to do.
Please let me know if it could be considered for inclusion, or how I might update it to be considered.
Thanks for the great module.
Comment | File | Size | Author |
---|---|---|---|
#2 | menu_block-active_trail-1339042-7.x.patch | 2.19 KB | AaronBauman |
#1 | menu_block-active_trail-1339042.patch | 2.12 KB | AaronBauman |
menu_block-active_trail.patch | 807 bytes | AaronBauman | |
Comments
Comment #1
AaronBaumanUpdated to loop on active trail array.
Comment #2
AaronBaumanThis issue persists into 7.x
Comment #3
AaronBaumanThis issue persists, although a partial solution has been deployed in 7.x-2.x
Updated title to be more specific
Comment #4
JohnAlbinOk. So the issue scope has changed from the issue summary. Can you explain why you'd want to examine the entire active trail instead of just the active page?
Comment #5
AaronBaumanIf the full menu tree isn't built, this function bails, and the proper menu_block doesn't get rendered.
I haven't identified under which conditions the menu tree is incomplete.
Comment #6
JohnAlbinHuh? If the current page isn't in any menu, the menu tree doesn't need to be built. That's by design. You seem to want to change the design. I was asking why.
Comment #7
AaronBaumanI'm saying sometimes the menu tree doesn't get built, even though the current page is in the menu.
I've noticed this behavior most recently when using Menu Position module.
I'm not intimately familiar with the menu system, but I think this could happen when menu_set_active_trail() is invoked after the menu tree has already been built.
Comment #8
JohnAlbinThat sounds like #1524674: Use of $_GET['q'] ignores menu_position module which is fixed in the 7.x-2.x-dev version.
Comment #9
AaronBaumanOK, I will take your word for it on D7.
I'm hitting this issue on a 6.x site, which I realize is reaching end of life, so please change status as you see fit.
Comment #10
JohnAlbin