<?php
print theme('links', $primary_links, array('id' => 'my_id_name'));
?>See http://api.drupal.org/api/function/theme_links/6
Matt Farina
Geeks and God Co-Host
www.innovatingtomorrow.net
www.mattfarina.com
Thanks for your reply Matt. This code works great, my only question is how would I output the full tree with the nested list items?
I tried combining what you gave me with the code I was using to print the full list like so...
<?php
print menu_tree($menu_name = 'primary-links', array('id' => 'my_id_name'));
?>This gives me the full list with the nested menu items but doesn't assign an id to the top level ul. Is there something I'm missing?
@rickhocutt looking at the code you posted I notice it's not following the api for menu_tree. Using my trust http://api.drupal.org and the function I would do something like...
<div id="some-name"> <?php print menu_tree('menu_name'); ?> </div>
Then I would reference the specific uls via the wrapper div.
That's what I did, and it works fine for nested css menus. Just wrap the menu in a div, and use standard parent/child selectors to reference it.
div#some_name ul {
/* first level css code*/
}
div#some_name ul ul {
/* second level css code */
}Since I'm not a javascript guy, I don't know if this would work if you wanted to manipulate the menu via ajax or javascript. Someone smarter than I would need to answer that.
Tony
Hey guys,
I was wondering how I might output my primary-links menu with a specific id asigned to the top level ul.
I am trying to achieve the following:
<ul id="main_nav"><li>Home</li>
<li>Products
<ul>
<li>widget 1</li>
<li>widget 2</li>
</ul>
</li>
<li>Contact</li>
</ul>
I haven't found a clear explanation of what to put in either the template.php file or my page.tpl.php file to achieve this.
I have tried manipulating this code
<?php print menu_tree($menu_name = 'primary-links'); ?>and this:
<?php$my_menu = menu_tree('primary-links');
$my_menu = str_replace("leaf", "", $my_menu );
$my_menu = str_replace("active-trail", "", $my_menu );
$my_menu = str_replace("menu", "", $my_menu );
$my_menu = str_replace("active", "", $my_menu );
$my_menu = str_replace("expanded", "", $my_menu );
$my_menu = str_replace(" class=\"\"", "", $my_menu );
print $my_menu;
?>
Without much luck.
Any help is appreciated!
Thanks
Rick
"For what will it profit a man if he gains the whole world, and loses his own soul?" (Mark 8:36 NKJV)