I would like to modify the output of markup for the node tabs. Out of the box the markup looks like this:

<div id="tabs-wrapper" class="clear-block">
	<h2 class="with-tabs">Some headline</h2>
	<ul class="tabs primary">
		<li class="active">
			<a class="active" href="/node/4">View</a>
		</li>
		<li>
			<a href="/node/4/edit">Edit</a>
		</li>
	</ul>
</div>

For better css styling options of the tabs I would like to modify the output to be like this:

<div id="tabs-wrapper" class="clear-block">
	<h2 class="with-tabs">Some headline</h2>
	<ul class="tabs primary">
		<li class="active">
			<a class="active" href="/node/4"><span>View</span></a>
		</li>
		<li>
			<a href="/node/4/edit"><span>Edit</span></a>
		</li>
	</ul>
</div>

Now, I've read a lot about 'hooks' and 'override code' etc., but I have to admit, that I didn't quite understand it. Where would I have to look for the code that produces the output for the tabs? And how would I change/override the code to accomplish my needs?

Any help to bring me back on the right track would be greatly appreciated. Thank you.

Comments

pobster’s picture

There's an example for exactly this about halfway down this page;

http://drupal.org/node/173880

If you want to google it yourself the key words you're looking for are; menu_local_tasks, template, preprocess

Pobster

DragoonBoots’s picture

This is a great example of when to try out the Devel Module's Theme Developer tool. It allows you to find out what template file you need to change or what function you need to override to change anything Drupal outputs (that can be themed, of course).

Norrin’s picture

Thank you very much guys, you've been of great help, but I'm still not where I would like to be.

Here's the status quo after reading the above mentioned page and using the devel module:

The devel module tells me that the 'theme_menu_item_link' produces the output for the above mentioned tabs link-markup. So far so good.

As I want to specifically add a <span>-tag within the <a href>-markup of the link, like

<a class="active" href="/node/4"><span>View</span></a>

I found out, that the function l() to be found in 'includes/common.inc', line 1554, needs to be tweaked. Changing the according line in the common.inc file gives me exactly what I want.

But knowing, that it is bad style to change the core files regarding future updates etc. I copied the function l() code and pasted it into the template.php file and tweaked it there, hoping it would override the original function. Now I get a fatal error telling me, that l() cannot be redeclared.

So, I suppose I'm still missing a tiny little piece of understanding the whole story.

Hope I was able to make you get my point and help me find the last piece of the puzzle.

Thank you ever so much once again.

pobster’s picture

You have to prefix l() with the name of your theme, e.g. mytheme_l() although... You're missing the point here, as this will override *every* l() across your entire site. Just have a good read of the link I posted above, it should be clear enough? That's one of the better pages in the handbook...

Pobster