2

This other SO post says that Context provides this functionality out of the box, but when I add settings which seem reasonable, the active and/or active-trail classes are not set on my menu items.

How am I supposed to configure Context to set the active and/or active-trail on my menu items?

Here is my set up:

I've added some terms to the standard Tags taxonomy. For example: Surf, Skate, Volleyball.

I've used Pathauto to set dynamic paths for my taxonomy terms. blog/Surf, blog/Skate, etc.

I created a Menu with an item called Surf with a path of blog/Surf, as well as for Skate and Volleyball, etc.

I added that menu to the Highlighted region of my site.

When I browse to blog/Surf, my menu item does not receive the active nor the active-trail class so that I can style it appropriately to show the user that is where they currently are in the site.

I tried creating a Context for it and guessing at how it should be configured.

How do I get the active and/or active-trail classes on my blog/Surf menu item?

enter image description here

1
  • Have you tried adding a "Debug" reaction? Does it say in message area "Active context: X" when you're viewing a node tagged with "Surf" term?
    – Beebee
    Jan 2, 2013 at 10:24

1 Answer 1

2

The only reason I can think of is that the context modules is actually adding the trail classes but the theme that you are using is not using them.

You can verify this in two ways,

  1. Change the theme back to Bartik and see if it works.
  2. Checkout the template file of your theme, print the variables that are passed to theme_menu_item in your template.php file

If the problem is your theme, then you will need to override the theme_menu_item accordingly in your theme.

2
  • 1
    I'm using a Zen theme, but I tried switching to Bartik anyway and that doesn't change anything. The Surf menu item does not get the active and/or active-trail classes. Jan 1, 2013 at 20:35
  • 1
    Good call on checking with default theme. I was outputting menu in template, and active trail was not being added for whatever reason. So I moved it to a region and added into a sitewide Context and now it works. Jan 15, 2016 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.