Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
i can't get it to work to set a menu active, when a certain condition is given. the problem is, that i don't know how to handle this advice "To use this feature, you must use theme_context_links() to theme your links".
where and how do i manage this?
thanks in advance
Comments
Comment #1
yhahn CreditAttribution: yhahn commentedSorry, this helptext is very out of date. I've updated it with this commit http://drupal.org/cvs?commit=225056
When using the active menu reaction, the links you've selected will get an active class in the $primary_links or $secondary_links of your page.tpl.php. All you need to do after that is add the appropriate CSS in your theme.
Comment #3
ranavaibhavHello,
I'm sorry if I'm not suppose to re-open issue, but i did because I'm facing similar problem.
I have set one of my primary link menu to be activated when I'm in a context section (i have set context for all story pages)
When ever I'm viewing a story page i see the context is being activated in the context devel block however the menu item is not being activated.
I tried changing the active menu setting to the secondary menu item as well as my custom menu item, but no luck.
I tried different theme to make sure the problem is not with the theme I'm using (tapstry)
I also tried the committed version of "context.core.inc" file from the above link (comment #1)
Please advise what else could be an issue? Thanks.
Comment #4
tancIt doesn't appear to do anything for me either. Looking through the code, I'm struggling to find anywhere that adds an active class to a menu item.
Comment #5
tancOk, I worked out that there is a preprocess page function which should set the active link in the function context_preprocess_page(). I had my $primary_links variable turned off in the theme settings so it wasn't being populated. Once I'd switched it on it still wasn't altering it in context_menu_set_active(). The $links variable gets populated with the primary links array but only the top level of the menu system. I don't know if this is by design as I don't know a lot about the internal workings of Drupal's menu system.
Aside from all this, my main problem is that I'm using 3rd party modules to style my links. I have Nice Menus displaying a horizontal drop down menu and Menu Block displaying a sidebar block with the current Primary Menu Links' children. I would need to add active classes to both these blocks for this feature to work. Any ideas how this can be achieved?
Comment #6
rossymole CreditAttribution: rossymole commentedHaving the same issue, using the Context Devel block and setting other context functions I believe I have context configured correctly, yet no active menu state. Ideas?
Comment #7
snufkin CreditAttribution: snufkin commentedThe primary links will not set active if you use them through the primary links block. The workflow for rendering blocks doesn't allow context to intervene and change the menu structure as it does with the page preprocess.
Comment #8
q0rban CreditAttribution: q0rban commentedRe: #5
I used some jquery to get nice_menus to work with active and hovered items, if you're interested:
Nice thing about this is it also adds a hover class to the parent item when you are hovering over a child item. Hope that's helpful...
Comment #9
q0rban CreditAttribution: q0rban commentedTo get this working with nice_menus, you can also (in theme foo, e.g.) override the theme_nice_menu_build function like so:
Comment #10
monteco CreditAttribution: monteco commentedI was having the same problem as tanc with my Nice Menus, and q0rban's nice_menu_build function worked for me. Thanks!
Comment #11
Steven Jones CreditAttribution: Steven Jones commentedI think that we just need some documentation about menu links and setting them to be active.
Comment #12
Steven Jones CreditAttribution: Steven Jones commentedAdded the help in http://drupal.org/cvs?commit=357604