How can I add a caption to a navigation menu in Drupal 6? I am trying to achieve this effect:

2 Answers 2

function MYTHEME_menu_item_link($link) { 
  // Debug:
  // dpm($link);

  // Check menu item localization settings:
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();

  // Target the desired menu:
  if ($link['menu_name'] == 'primary-links' && $link['options']['attributes']['title']) {

    // Theme menu item description:
    $desc = '<span class="menu-item-desc">' .
      check_plain($link['options']['attributes']['title']) .

    // And title:
    $link['title'] = '<span class="menu-item-title">' .
      check_plain($link['title']) .

    // HTML should be enabled:
    $link['localized_options']['html'] = TRUE;

    // Theme the menu item title as a link, then append the description:
    return l($link['title'], $link['href'], $link['localized_options']) . $desc;
  // For other menus:
  else {
    return l($link['title'], $link['href'], $link['localized_options']);
  • Place this into your theme's template.php
  • Don't forget to flush your Drupal cache at admin/settings/performace (D6)

You will need to apply some theme overrides in template.php, the most important function for you would be the theme_menu_item I would imagine, this will allow you to change the structure of the LI and include a description from the menu item. The images should be achievable from using css id's.

Also see the documentation


function theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
// Dont forget to include code from the default for active trails etc, then add something like below to add on the description:
if ($link['menu_name'] == "*YOUR MENU WHICH YOU WOULD LIKE TO CHANGE*"){
  $link['title'] .= '<span class="description">'.$link['description'].'</span>';
return l('<span>'.$link['title'].'</span>', $link['href'], $link_options);
  • thanks for your answer westieUK , I actually need to print my menu description too, since i'm quite new to drupal i'm using custom template that there's no template.php in it, so should I copy it from another theme like garland and add your snippet to it?
    – Sohail
    Mar 27, 2012 at 8:30
  • That is correct, you might want to strip out some of the functions in case of a conflict, also rename the "theme" part to the name of your theme.
    – WestieUK
    Mar 27, 2012 at 9:11
  • 2
    in this function you don't have access to $link array, that's already themed as a anchor element. You should use YOURTHEME_menu_item_link, I guess.
    – sepehr
    Mar 27, 2012 at 10:33
  • Good point I guess you would want the whole button clickable as an anchor rather than just the title...
    – WestieUK
    Mar 27, 2012 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.