views:

328

answers:

2

Hi there,

I have some styling based on the primary links active class. I would like to set the class of a link in the primary links to active (<a class="active"...>) based on either the content type or the path.

I have already done some research on this but haven't yet seen anything that seems to match my query.

Would be grateful for any help.

Ben

A: 

The contributed module Menu Trails is want you're looking for. You can then set a menu trail based on content type.

Fabian
Hi Fabian, Thanks for your answer. That sounds like it'll solve my problem. I guess I was kinda hoping someone might show me how to do it using theme_links() or similar and I might learn something!Ben
Ben
Just implemented it and works great. Thanks again.
Ben
A: 

Hi Benmango,

check out context module (development seed). It gives you a nice interface to set a context for your site or section within. You can have a news section with the path "news/node-title" and context would set the news menu item active. It does a lot's of cool things beyond this, like granular block management.

Parts of contexts concept will merge into D8 menu/routing system. ;)

Regards

Mike

mikewink
Hi Mike, thanks for your answer. I did have a look at the context module. It looked quite complex. Or in other words take me longer to implement than menu trails. If I'm in a similar position again, i will certainly consider using it.
Ben