Last updated November 6, 2014. Created on June 12, 2006.
Edited by jasom, Scott J, johnv, ronald_istos. Log in to edit this page.

Edit your page.tpl.php

Edit the section where the primary_links are printed to show the whole primary links menu instead of only showing the first level links of your primary links menu.

<?php if (isset($primary_links)) { ?>
<div id="primary_menu">
<?php print theme('menu_tree',variable_get('menu_primary_menu',0)); ?>
<?php } ?>

In Drupal 6

$menu_name = variable_get('menu_primary_links_source', 'primary-links');
print menu_tree($menu_name);

Drupal 7

    $menu_name = variable_get('menu_main_links_source', 'main-menu');
    $tree = menu_tree($menu_name);
    print drupal_render($tree);


  • You can define, what menu the primary links are from at "admin/settings/menu" (D5) or "admin/build/menu/settings" (D6), or "admin/structure/menu/settings" (D7).
  • Another way to just show the second level of your primary links is to setup that the secondary links show the second level of your primary links (also at "admin/settings/menu")
  • The benefit of the snippet above is, that you can display N-levels of your primary links menu and that it is printed as an unordered list with css classes "active", "expanded" and "leaf" like by default. Just like the menu items in a block menu.

Looking for support? Visit the forums, or join #drupal-support in IRC.


espirates’s picture

I notice a difference between using primary links as a block vs hard coded in the page. When in page.tpl the secondary links display child page of a primary link, but with the block the child page is tucked underneath the link and uses a drop down menu. Are there any pros and cons to using the link blocks vs coded in the page. I was hoping the block would have the same behavior as the code.

Wolfflow’s picture

My IMO is that using Block for Primary and Secondary Links may give you a lot of more control about css layout and custom PHP code. Of course this presume that you would have to know a bit more about PHP coding. On the other Side if you use multilingual site functionality and also taxonomy you will have a bit of more work to learn and manage Drupal-core coding.

Learning for Module Developer Status

wangweilin’s picture

Hi can somebody help me.

My page is setup for two languages at the moment and I set the primary and secondary link source to the primary links.
So I get the childs of my primary links in the secondary link part of my theme.

All works fine in english but in german the children are not shown. Can anybody help me what to do about that.

Toongenius’s picture

Don't know if I'm doing something wrong, but this does absolutely nothing for me. I'm still stuck with nothing but the top level nav.

charlie-s’s picture

Same here. Only printing top-level items.

Shinzon’s picture

Got one question about this. This code generate navigation with class "menu"
Something like this:

<ul class="menu">

How can i change that "menu" into something diferent?

Toongenius’s picture

Hard coding it is a bad idea.
I set my primary links up as a nice menu (using Nice Menus Module) and then I could style it however I liked with all the child links showing up. Problem solved!

jasom’s picture

-- deleted, I was wrong.

cmbehr’s picture

make sure your parent items have "expanded" checked

JustSpiffy’s picture

The "expanded" checkbox is set on all my menus. I still cannot see anything but the parent menus. Moving a menu item under another menu item makes it invisible. Moving it back to the top of the hierarchy makes it reappear.

karlitros’s picture

Have a look at this blog post. You can grab the whole primary links structure including children, and clean it up ready for use using that. :)

adityamenon’s picture

That page should be put on the currently inadequate manual (at least as far as the menu functions are concerned)... and also on the tutorials page, since this is a very common requirement.

pelsdyret’s picture

I've been looking for a solution for hours. I just wanted the second level menu items of my main menu shown elsewhere.
The Menu Block module did the trick!

jpvivere’s picture

After a fresh 7.10 install, I was having trouble with my sub-menu items not showing up after clicking on the parent menu items. After searching the forums for a while for a solution, to no avail, I found out that my node was somehow corrupted or misappropriated. After deleting the "basic page" and recreating it again as a new node, the menu sub-items for that replaced node/menu-link began working normally (it previously linked to node/1 and then became node/5).

Also, moving the menu items around (drag-n-drop) in Home » Administration » Structure » Menus seemed to reveal the problem (i.e., the sub-menu items appeared when moved to a separate parent menu item).

I didn't dig through the code enough to discover a problem with the build, but I though I may share this with others who may be trying to find a solution to this problem--it may be a problem with the node and not the menu structure/configuration.

jasom’s picture

-- deleted, I was wrong.