Ok i've done some searching and I think I understand how to do this, but I'm getting an empty array when I try and print out my custom menu.

Steps:
1. Went into the admin and created a new menu called Login_logout (it's pid is 99, i got that by hovering over it's edit link: http://domain.org/admin/build/menu/menu/edit/99 )
2. Added two menu items (Login and Logout)
3. Went into my page.tpl.php and added the following code

$pid = 99;  // This would be the menu id of one of your new menus.
$menu = menu_primary_links(1, $pid);
print_r( $menu ); // <-- this prints an empty array
print theme('links', $menu, array('class' => 'some_class')); // <-- this prints nothing

Any thoughts to what I'm doing wrong?

TIA

Comments

shawn.sh’s picture

Hi msteudel, I copied and pasted your exact code just to reproduce your situation (only changing the pid) and it worked fine on my d5 install.

--
Shawn Gregg
www.shalosophy.com - blog
www.gmndesign.com - portfolio

msteudel’s picture

Thanks for checking! That helps me at least narrow things down.

MS

amariotti’s picture

Argh! Why does this stuff only work in 5.x and not 6.x?

http://drupal.org/node/403934

Philip Hollings’s picture

Though a very newbie to D6 I found this to work ..just needs styling up using a class:

where :
"menu-myname" is the D6 name of the menu [ not a node or menu ID :-) ]
0 at the end of the call to menu_navigation_links is the default level, I suppose if you want to descend further you can (I didn't).
and "my-class" is the style to apply to the output.

<?php 
	$menu = menu_navigation_links('menu-myname', 0);
	print theme('links', $menu, array('class' => 'my-class')); 
?>
shrimphead’s picture

This code didn't quite work for me so i replaced theme('links') with theme_links().

$menu = menu_navigation_links('menu-submit-links');
$menu_attributes = array('class' => 'submit-links');
print theme_links($menu, $menu_attributes); 

Works in D6.20

heyehren’s picture

Hi all,

i've put together a tutorial on custom menus. I hope it helps a few people.

http://www.kleinermann.com.au/blog/add-a-custom-menu-in-drupal-6/