1

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.

5

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. – Lester Peabody Aug 1 '11 at 20:29
0

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, privacy policy and cookie policy

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