- Context configuration -
Namespace: context_ui
Key: section
Value: events
Content types: Events
Menus: Primary links > Events
Expected result: The menu item 'events' should gain an 'active' class when viewing event nodes. It doesn't appear to work in the dev release from 11 June.
Comments
Comment #1
yhahn commentedHey Ronanw,
Does your menu markup look like this:
If it does, then the context UI menu handling is actually working correctly. By default, the Drupal menu system makes the "active" class of menu items rather inaccessible to themers by concatenating it onto the menu class -- "menu-1-1-2" in this example. You can make it usable by overriding theme_links or theme_menu_links. Here is an example of a theme_links override:
On the other hand, if your markup doesn't have any traces of active classes at all, please post back to let me know. Thanks!
Comment #2
Rowanw commentedI'm currently using the Primary links block to display the menu, which doesn't give any active class when viewing an event node. If I print
theme('menu_links')in page.tpl.php (+ your theme override) then the active class is applied correctly, however as far as I can tell this doesn't give me a hierarchical/nested list, which is what I need.Would I have to do something special with
theme_menu_item()to get this working? Also, is Context module able to 'expand' a menu when it's active?Comment #3
yhahn commentedHey Ronan,
Sorry for the late reply. Fortunately the blocks provided by the menu module go through theme_menu_tree which means you can override their default behavior. Unfortunately, theme_menu_tree looks like this:
Meaning that the majority of the logic for building these menus is relegated to the menu_tree() function. You may want to take a good look at this function as you can definitely capture the behavior you need by modifying it (rather, create a copy of it and point your override of theme_menu_tree at your version). You may also need to modify theme_menu_item().
In general, I've been running into various snags with Drupal 5's menu system that makes context_ui's behavior with it a little rocky (for example, after your context definitions have set how the menu should behave, another module can come along and alter that). I'll be doing some serious study for the Drupal 6 version which hopefully will be able to avoid some of these problems thanks to the new menu system.
Let me know if I can be of any more help!
Comment #4
Rowanw commentedThanks yhahn, I just tried the latest dev release and it now appears to expand menu items correctly, which for our site is essentially the same as making it 'active' (since the main menu will always have a second level).
I'll try the approach you suggested when I can't simply rely on the expanded state though.
Comment #5
yhahn commentedGlad it's working -- I'm closing this for now.
Comment #6
gagarine commentedSame issue with the 6.x-2
Comment #7
gagarine commentedComment #8
cruzinxxx commentedmy markup doesnt have any traces of active class. I used the menuclass module to create user defined class names, because I had to upload an image instead of text for menu items, but now the active class doesnt appear anymore. I need that too, to set additional properties...could you help me
Comment #9
pendashteh commentedi solved the problem of my case.
i had a primary menu like this:
---Overview
|
+--- Home
|
+--- News
|
+--- Gallery
|
---Products
|
+--- ...
i wanted to active News menu item when in story nodes.
in Context Reaction i set Menu as News, but it did not apply. it even did not expand the Overview menu.
i solved by doing this in template.php and using some code from the module:
Comment #10
pendashteh commentedoh, my solution just hide the "View, Edit, Translate" tab menu over the node.
Comment #11
pendashteh commentedi SOLVED it in my case like this:
if you use menu_block module instead of
use:
Comment #12
pendashteh commentedFinal code:
Comment #13
gagarine commentedThanks for your work.
But bugs are marked as fixed when code are committed. Please submit a patch http://drupal.org/patch/create and change the statue of the bug to "need review" more infos http://drupal.org/node/156119. If you have a problem to create a patch feel free to ask on the forum :).
Comment #14
markabur commentedaliasghar's code is only applicable to context v3.
Comment #15
steven jones commentedThis is probably just another case of needing some documentation with these things in it.
Comment #16
steven jones commentedDon't think it's critical.
Comment #17
steven jones commentedAssigning to me
Comment #18
steven jones commentedLooks like this issue is a duplicate of #653698: Menu Trail Condition incorrectly displays depth, because we're not actually setting the active menu trail.
Comment #19
nedjoRelated patch: #835090: Context Reaction: Set menu trail.