Maintainers, thank you--I'm enjoying the power and flexibility of this theme.

Working on my first subtheme, I'm stubbing my toe on what may be a simple issue: how to add a span tag to the primary and secondary menu links so I can theme them as tabs.

I want to change the output from this:

<li><a href="/">home</a></li>

to something like this:

<li><span><a href="/">home</a></span></li>

I've followed directions from threads like this one (http://drupal.org/node/801412), but find the structure of this theme differs from the more "standard" template.php / page.tpl.php layout I've used with other projects. (And I'm not at ALL experienced in Drupal coding, so bear with me.)

So adding this code to template.php hasn't yet worked:

function organizedhome_preprocess_page(&$vars) {
    
    $links = $vars['primary_links'];
    
    foreach ($links as $key => $link) {
        $links[$key]['html'] = true;
        $links[$key]['title'] = '<span>'. $link['title'] . '</span>';
    }
    
    $vars['primary_links'] = $links;
}

Adding this code to page.tpl.php isn't getting anywhere, either:

theme('links', $primary_links, array('class' => 'links primary-links'));

Anyone have pointers for me on how to add these needed span tags? Thanks in advance.

Comments

himerus’s picture

You would actually want to use theme_links to override the default link building structure.

You could do this in a couple ways... by overriding the theme function in your template.php using yourtheme_links, or creating a duplicate of the function theme links that was called yourtheme_customlinks.

The first option would allow you to overwrite the implementation anytime theme('links' was called.
The second option would need you to then, in preprocess-page.inc you would need to do something like:

$vars['main_menu_links'] = theme('customlinks', $vars['primary_links'], array('class' => 'links main-menu'));
$vars['secondary_menu_links'] = theme('customlinks', $vars['secondary_links'], array('class' => 'links secondary-menu'));

himerus’s picture

Status: Active » Fixed

marking as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.