I have a secondary menu that displays like:

<ul class="secondarynav">
<li class="menu-428 first">
<a href="/content/page">PAGE</a>

I would like to change that so it displays a <span> on the links like:

<ul class="secondarynav">
<li class="menu-428 first">
<a href="/content/page"><span>PAGE</span></a>

According to the Drupal 7 theme_menu_link documentation and this answer on theming Drupal 7 menu links, I should just be able to declare a hook like THEMENAME_menu_link__MENUNAME($variables).

I've declared the following two functions in my template.php, but neither of them is being called:

function MYTEMPLATE_menu_link__system_secondary_menu(array $variables) {die;}
function MYTEMPLATE_menu_link__secondary_menu(array $variables) {die;}

I'm using Framework, and there's a section like:

if (isset($vars['secondary_menu'])) {
    $vars['secondary_menu'] = theme('links__system_secondary_menu', array(
        'links' => $vars['secondary_menu'],
        'attributes' => array(
        'class' => array('secondaryNavigation'),

What's the cleanest / best practice-y way of printing an extra <span> in the menu links for this menu only?

I can write a function to theme the entire menu at once with function MYTEMPLATE_links__system_secondary_menu(array $variables), but theming the entire menu just to get a <span> in each link seems like overkill.

2 Answers 2


It calls theme('links__system_secondary_menu'). By default, there is no theme_links__system_secondary_menu, so I guess it is calling theme_links. Looking at the function, all you have to do is copy it to your theme as THEMENAME_links__system_secondary_menu, then change the call to l() to something like:

$link['html'] = TRUE;
$output .= l('<span class="whatever">' . $link['title'] . '</span>', $link['href'], $link);

The html => true is required or l() will strip the html out of its first parameter.


For custom menus (created by you) the MENUNAME is the machine name of the menu (obtainable by visiting the menu edit page) with dashes converted to underscores. So for a menu called 'Secondary Menu' the machine name should be 'secondary-menu' (make sure to check) which converts to 'secondary_menu'. So you should implement THEMENAME_menu_link__secondary_menu(array $variables).

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.