views:

519

answers:

3

hi! i want to add id tags to primary links menu.. it should look something like this:

<li><a id="home" href="#">Home</a></li>
<li><a id="about" href="#">About</a></li>
<li><a id="contact" href="#">Contact</a></li>

currently, it's just

<li><a href="/test/drupal/content/home">Home</a></li>
<li><a href="/test/drupal/content/about">About</a></li>
<li><a href="/test/drupal/content/contact">Contact</a></li>

to change the address to "#" is it ok to use url aliases?

I just want to add attributes to l() when it creates the primary menu, thatz it in a nutshell..

any suggestions? should i edit any file or create new function to do this job? I'm using zen theme(just for an info) many thanks..

+2  A: 

It seems like you want to alter the links, so you can add some js tabs. If that is the case:

  • You shouldn't alter the href value of the links, since it will just break your navigation for those that doesn't use javascript.
  • If your aim is to add the id's to use them for js, your best option would be to add them using js.

In Drupal, there are some different ways to alter the output of the primary menu.

  • You can alter the drupal output for menus using theme_menu_item_link, this wont help much though, since, that function is used for all menu items.
  • Alternative you can handle creating the primary menu yourself in your template.php, but this is probably not worth the bother in this case.
googletorp
"Alternative you can handle creating the primary menu yourself in your template.php, but this is probably not worth the bother in this case."what do u mean by that?
almac
What you would need to do, to get this to work, would be to create your own functions to generate the primary menu. Some of it you could do with APIs but some you would need to do yourself. So you would basically throw out what Drupal does as standard and implement your own thing. It's a bit ugly, but it would get the job done.
googletorp
googletorp,instead of creating a primary menu, i created a block and coded my navigation links there..not a good idea though :(it's be helpful if there is a module to do that..
almac
+1  A: 

Have you looked at using the Menu Class module? You can create menu class sets and then assign them to each individual menu items.

Brent Hardinge
thanks Brent, will have a look and comment..
almac
Brent, maybe this does not solve the problem of the OP, but yours is an excellent find, I've always wanted to get this functionality! (+1) :)
mac
A: 

I use the menu attribute module. Works great!

ahimsauzi

related questions