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.


2 Answers 2


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.

  • Wow, unbelievably powerful. Way easier than creating a hook. +1, cheers mate. Aug 1, 2011 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().

Your Answer

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

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