Closed (works as designed)
Project:
Context
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2011 at 13:36 UTC
Updated:
1 Jun 2011 at 07:17 UTC
Setting active menu items currently doesn't work. The context is run in context_preprocess_page and the menu active item is set in $vars['main-menu'] but I have a feeling that that is too late - links are probably already rendered.
Comments
Comment #1
febbraro commentedCan you describe the exact steps to reproduce the problem?
hook_preprocess_page is exactly where it is supposed to be happening
http://api.drupal.org/api/drupal/includes--theme.inc/function/template_p...
We have a unit test that passes and I have verified that it works as expected. What are you seeing that is different?
Comment #2
meba commented1) Create a menu with some submenu items
2) Create a node in the menu
3) Create a context, activate it, put menu item as a reaction
The menu is in block-system-main-menu, rendered in page.tpl.php using render($page['navigation'])
Comment #3
febbraro commentedI'm sorry I still dont quite understand what you are expecting to happen and what is actually happening.
Are you implementing hook_preprocess_page and doing anything? What appears to be missing?
Comment #4
Christopher Camps commentedThe problem occurs when a menu is rendered in a block.
It works fine when a menu is rendered directly inside page.tpl.php with $main_menu.
To see it fail, add the main menu as a block in Bartik and try to highlight one of the items with a context.
Comment #5
Christopher Camps commentedComment #6
febbraro commentedTurns out that Context can;t really solve this problem easily. It sets active on the menus in Primary or Secondary links, not in any old block. Reason is that the block and menu reactions are separate and they dont know about each other. Any solution I can think of at this point will be a disgusting hack.
Comment #7
rjacobs commentedFor reference, there is some work on this for Drupal 6 (#835090: Context Reaction: Set menu trail) which attempts to create a new reaction that sets the active menu trail (which themes can also use for styling active menu items).
I'm not too sure how that translates to D7, but there seem to be several advocates to get this kind of a reaction into context in general. I believe it could solve some issues like this (assuming the theme is able to go something with "active-trail" classes).
Ryan