By jmlane on
Hey,
I'm trying to find a way to rewrite the XHTML generated for primary links. I'm using PHPtemplate engine. The reason I need to modify the XHTML is because I'd like to add a class "first" to the anchor in the first list item generated for the menu, so it would look like this:
<ul id="primary-links">
<li><a class="first" href="/contact">Contact</a></li>
<li><a href="/forum">...</a></li>
...
</ul>
Any suggestions on how I can go about this are greatly appreciated!
Thanks,
Jonathan
Comments
Problem solved, here is the
Problem solved, here is the solution, incase anyone wants to do something similar in the future (Thanks to Adrian for giving me an idea how to proceed):
You need to create a _phptemplate_variables() function in your theme's template.php file, which should resemble the following:
Okay, so now you've got the basic format. To add any custom attributes to your anchor, you simply have to add the logic in at the spot where I inserted the following code:
The format should be obvious from this example. $attributes['name of the attribute'] = 'value of the attribute';. You can have any number of these attribute statements, because it's an array. You just need to make sure your conditional statements and additional logic is correct.
Hope someone finds this useful,
Jonathan
Trying to do something similar...
I too wanted to modify the XHTML output of the Primary Links for the PHPTemplate Engine, but in a slightly different way...
My Primary Navigation link list takes on the appearence of "tabs". I noticed that the anchor tag may contain the "active" class if the user is on the same page that the link points to. What I wanted to do is move that class="active" attribute to the 'LI' element instead of the 'A' element.
I need it to be a level up, or add an element like a 'SPAN' inside the 'A' element so I can use the sliding door approach to make my image slices look like tabs.
If anyone can point me in the direction of how this is done that would be sweet!