Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a site that has a lot of menus. One of them is the main menu that has few items. These items link to main areas of the site, and each of these main areas has one specific menu. When I'm on a landing page of one of these main areas, the item of it on the main menu is active, but when I'm on an internal page of one of these areas, the item on the main menu is not active.

Is there any way to make it active automatically?

I tried using menu_position but it seems not be working.

share|improve this question
up vote 9 down vote accepted

Context provides this functionality out of the box.

share|improve this answer

Their is a lot of ways. I list here only things compatible with D7 and eventually on D6.

Use a modules

Code your stuff

Their is now a native API menu_tree_set_path to set the path you want to use to calculate the menu active trail.

You can also work in theme_links but but I recommend to use menu_tree_set_path so other module know what is your active link. The advantage is you can use this function in your theme without creating a module.

Keep in mind, menu_position has an API to create your custom rules.

So what should I use???

It's depend of your need. if you have simple rules like: for this node type/views/taxonomy i want this active menu, context is good.

If you have a good url structure (autopath) than follow your menu structure, menu_trail_by_path will just works without any effort.

I never used menu_position... so I can very tell.

If you need some special logic, coding your things is certainly faster than creating 40 context or rules...

share|improve this answer

The easiest way is just to make those menu items of your "internal" pages (subpages belonging to your areas/landing pages) children of landing pages menu items.

Something like:

primary links menu
+-- landing page 1 menu item
|   |
|   +-- internal page 1 menu item
|   +-- internal page 2 menu item
+-- landing page 2 menu item
    +-- internal page 3 menu item
    +-- internal page 4 menu item

If you have to keep them in separate menus though, you would probably need to play with theme_links() to keep proper "active-trail" and/or "active" classes.

share|improve this answer

Perhaps the Menu Block module would help you.

(In conjunction with the approach that Maciej outlines above).

From the Menu Block project page:

It provides configurable blocks of menu trees starting with any level of any menu. And more!

So if you’re only using your theme’s Main menu links feature, you can add and configure a “Main menu (levels 2+)” block. That block would appear once you were on one of the Main menu’s pages and would show the menu tree for the 2nd level (and deeper) of your Main menu and would expand as you traversed down the tree. You can also limit the depth of the menu’s tree (e.g. “Main menu (levels 2-3)”) and/or expand all the child sub-menus (e.g. “Main menu (expanded levels 2+)”).

share|improve this answer
I tried Menu Block but it didn't worked as expected – Luiz Guilherme Sep 16 '11 at 16:30

Your Answer


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.