My menu structure looks like the structure in the left part of the image. I want the output to look like the right part of the image when I'm in the 'oranges' page for example. This works great if done from Drupal's admin panel, but is there any way I can code it in my page.tpl.php?

enter image description here

Currently, I'm using the code below to output my menu, but I can't seem to get it to look exactly the way I want.

  $main_menu = menu_navigation_links('main-menu', 2);
  print theme('links', array(
  'links' => $main_menu,
  'attributes' => array(
  'id' => 'main-menu',
  'class' => array('links', 'clearfix'),


  'heading' => array(
  'text' => t('Main menu'),
  'level' => 'h2',
  'class' => array('element-invisible'),

Any ideas?

1 Answer 1


You can use menu_tree_all_data function to get all nested menus. And then you can add your own html to display menus with your style

$menutree_produce = menu_tree_all_data('menu-produce');

And if you want to Active current menu on related page you can use menu_get_item and menu_set_item on that page

$menu_item = menu_get_item(drupal_get_normal_path('produce/oranges'));
menu_set_item(NULL, $menu_item);

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.