Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I need to activate an existing menu item through a hook when I'm on a certain page. To give some context, I have a primary navigation bar which is visible on all pages, and when I'm on a user profile page I want to activate the People menu item. The path to people is /people. Any help is appreciated.

Cheers.

share|improve this question

2 Answers

up vote 4 down vote accepted

I would recommend using the Context module. You can setup rules for when a menu item is active such as content type or menu path which will save you from writing related code.

This might make it easier to understand as well for someone inheriting your site.

share|improve this answer
 
Wow, unbelievably powerful. Way easier than creating a hook. +1, cheers mate. –  Lester Peabody Aug 1 '11 at 20:29

While not a hook maybe this will help.

If you are using a menu block you can just Show block on specific pages (in Home » Administration » Structure » Blocks). Select "Only the listed pages," and enter "people" "people/*" (for pages such as people/joe, people/amy).
This is for if you aren't using Context or Panels which are much more flexible.

Check out also hook_block_info().

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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