I have been working on a theme and I'm trying to figure out how to change the primary links from displaying in a UL tag set. I'd like to place them in a separate DIV or SPAN for each link.

Currently in my theme I have this line of code to create the link list

print theme('links', $primary_links, array('class' => 'primary_links', 'id' => 'navlist'))

I understand that it builds the link list and that I can specify the class and ID but how does the theme system know that I want them in UL and LI tags and where is it so I can change it?

Thanks in advance!

Comments

Jeff Burnz’s picture

This gets asked a few times per month, the real question in my mind is - why?

I mean, the answer is pretty much staring you in the face - modify the the theme_links function, but why bother going to all the effort just to change the HTML?

They're all just block or inline elements, the styling possibilities are not limited by using lists, and lists are the conventional wisdom for outputting menus, and probably the closest thing we currently have to semantic mark-up for them.

jeremyr’s picture

I understand what you are saying and I likely deserve that response for veering from "good" coding practice, however, that doesn't change that I'd like to learn how to change that code.

With that said, where is this "theme_links" function you speak of? or what file should I write it in to?

W: jprasmussen.com

Jeff Burnz’s picture

I've just been blogging about modding the theme_links function, slightly different topic but the function is there and some nice other links as well.

jeremyr’s picture

Ahh... that's what I'm looking for! Thank you.

W: jprasmussen.com

nineteen’s picture

The question now is.. If you have say two sets of links on a page.. How could you write one with divs / extra stuff and one without? In other words.. How can you write TWO SEPARATE theme_links() functions.

This is frustrating me a lot!