Add tertiary links to your Drupal 6 template

By default, Drupal 6 provides for primary (level 1) and secondary (level 2) links in your page template. But what if you also want to display the children of the secondary links (the tertiary links) in a separate menu?

Copy the snippet below to a file called template.php residing in your theme's folder, replacing themename with the name of your own theme.

 * Override template_preprocess_page() to add the tertiary links 
 * to the page template.
function themename_preprocess_page(&$vars) {
  // This adds a variable called $tertiary_links to your page template.
  $vars['tertiary_links'] = menu_tertiary_links();

 * Returns the tertiary links
function menu_tertiary_links() {
  return menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), 2);

In your page template (page.tpl.php) you can now output the tertiary links in the following way:

<?php if (isset($tertiary_links)) : ?>
  <?php print theme('links', $tertiary_links, array('class' => 'links tertiary-links')) ?>
<?php endif; ?>

You'll need to clear the Drupal cache before your links will appear.