Hi folks,

I want to use a centered version of CSS tabs (refer to http://24ways.org/2005/centered-tabs-with-css for details if desired). In order to do this, the SPANs that enclose the A in my UL of links need to be reversed - that is the instead of having this:

<li><span><a href="/about">About Us</a></span></li>

I need this instead:

<li><a href="/about"><span>About Us</span></a></li>

The pertinent line that outputs this is in template.php and is shown below:

if (isset($link['href'])) {
        $output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
      }

So unfortunately, the output is not really exposed in the code. I think this change is still probably doable but my PHP is rusty to say the least. Can anyone suggest how I can move the SPANs to wrap the actual text instead of the anchor, so I can get my tabs to work? Possibly there is an alternate way to output the HTML so I can code the A as I desire using the $link attributes?

Thanks

Tom

Comments

jastraat’s picture

To modify those lines of code to have the span tags within the link tags, I think you could make the following change:

if (isset($link['href'])) {
        $output .= l('<span>' . $link['title'] . '</span>', $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
}

This may have unintended consequences, however, if other things are using that template.php function.

tdellaringa’s picture

THanks, I actually just tried that and what it does is put the actual text '' etc. into the link itself as text, it doesn't add it to the HTML. Any other ideas? I wish this were a little more exposed so it was more flexible.

jastraat’s picture

Hm... Well, you could always not use the link function and just set the output to the actual html that you'd like it to return.

jonjo’s picture

Did you ever find a suitable solution to this? I have exactly the same problem. Please let me know if you did. I could work around the l() function (as suggested) but it provides useful functionality that I would then need to duplicate, so I'd like to avoid this if possible.

Thanks in advance.

jonjo’s picture

Scratch that last comment. You can do it like this...

Basically let's say you had this before:

$output .= "<li id=\"t-$ltitle\" >". l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']) ."

Change it to this:

$output .= "<li id=\"t-$ltitle\" >". l('<span>'.$link['title'].'</span>', $link['href'], $link['attributes'], $link['query'], $link['fragment'], $absolute, $html = TRUE) ."

Note the added spans but also the bit added at the end which allows the l() function to accept HTML and not convert it all to text output.

Props to the original solution provider --> http://www.usingdrupal.com/node/20

RockSoup’s picture

I have been trying to get this to work, thanks to you I got it.

najibx’s picture

how about D6?
what's the equivalent D6 for http://api.drupal.org/api/5/function/theme_menu_links ?