almac
almac

Reputation: 65

adding id to a tag in drupal's primary menu

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..

Upvotes: 2

Views: 1527

Answers (3)

ahimsauzi
ahimsauzi

Reputation: 1

I use the Menu attributes module. Works great!

Upvotes: 0

Brent Hardinge
Brent Hardinge

Reputation: 43

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

Upvotes: 1

googletorp
googletorp

Reputation: 33275

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.

Upvotes: 3

Related Questions