Tertiary links on Drupal

Update: check Tertiary links / 2: treeĀ workaround before this. That’s a wiser solution in many cases.

Tested on:

  • Drupal 5.x
  • Zen subtheme

If you use primary and secondary links in distinct blocks/area of a page, you can add the ability to browse the third navigation level. Just hack your page.tpl.php.


<div id="secondary">
<?php
#display tertiary links menu on 2nd level
$tertiary_links=menu_primary_links(3, variable_get('menu_primary_menu', 0) );
#display secondary links menu on 1st level
if($my_secondary_links):?>
<?php
print theme('links', $my_secondary_links, array('class' => 'links tertiary-links'));
?>
elseif ($secondary_links): ?>
<?php
print theme('links', $secondary_links);
?>
</div> <!-- /#secondary -->
<?php endif; ?>

See also:

Customize links menu in Drupal

Tested on: Zen theme, Drupal 5.7

  1. Copy function theme_links from includes/themes.inc
  2. Paste it into your template.php
  3. Rename it in theme_primarylinks (or anything you want)
  4. In your page.tpl.php, change
    1. print theme(‘links’, $primary_links);
    2. to print theme(‘primarylinks’, $primary_links);
  5. Apply some changes to theme_primarylinks to customize your primary links.

According to theme manual, for any first argument passed to theme function a theme_functionname function is called.