Showing the child items of primary links / Turning primary links into "primary menu"

Last modified: August 26, 2009 - 18:32

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)); ?>
</div>
<?php } ?>

In Drupal 6

<?php
$menu_name
= variable_get('menu_primary_links_source', 'primary-links');
print
menu_tree($menu_name);
?>

Notes

  • You can define, what menu the primary links are from at "admin/settings/menu".
  • 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.
 
 

Drupal is a registered trademark of Dries Buytaert.