I have created a custom menu - called Custom Links
I want to display this menu in the same fashion as my primary links.
From my page.tpl.php file I can see that this is done as follows:
<?php if (isset($primary_links)) { ?><div id="primary"><?php print ('links', $primary_links) ?></div><?php } ?>
however, when I try the following, nothing appears.
<?php if (isset($custom_links)) { ?><div id="custom"><?php print theme('links', $custom_links) ?></div><?php } ?>
I can turn on the block that the menu module has created - 'Custom Links' - but this doesn't present the links in the same way as the primary links, and not in the place I want them tobe on the page. It presents them as an unordered list, rather than with a delimiter.
Can anyone let me know how to do this - I'm sure it's simple enough - I just have no clue!
Best Regards
Comments
PHPTemplate variables
From what I just wrote about them here:
http://drupal.org/node/112726
This is how the variables are set in page.tpl.php (for 4.7)
http://api.drupal.org/api/4.7/function/phptemplate_page
You can add your new $custom_links variable by following these instructions:
http://drupal.org/node/16383
And from:
http://api.drupal.org/api/4.7/function/menu_primary_links
you could do something like:
in your template.php file.
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
menu_primary_links() would
menu_primary_links() would be so much more useful to me if I could pass in the name of a custom menu instead of digging to find out the id to use ...
I used this solution with Drupal 6.3
<?php print theme('links', menu_navigation_links('menu-machine-readable-name'), array('id' => 'menu_id', 'class' => 'menu_class')); ?>
That's all I did and it worked perfectly. Hope it helps!
thank you
don't know about the others, but perfect for my specific problem. thanks :)
King among Men
You sir are a king among men! I've been looking into this for the past few days and finally came across your post.
I have been wanting to make a custom menu my primary menu. I have a segmented my site into mini-sites using sections and path-alias. With all that set up, i wanted each section to have it's own menu displayed as the primary menu. Using the code above i changed the last bit to the following:
print theme('links', menu_navigation_links('menu-custom-menu-1'), array('class' => 'links primary-links'));
My custom theme now displays a custom menu for the specific section!
Thanks again
- nunami
anyone?
I am looking for this as well. Looks like something very simple. So how to include that custom menu as part of your theme? And how to find menu id in Drupal 6?
Sorry, bumping this thread.
Sorry, bumping this thread. I'm wondering the best way (drupal 5.7) to include a custom menu into the page.tpl.php?
As per the first response to
As per the first response to my original post - use template.php to define the menu and then include it where you like in your page.tpl.php file.
To find the menu id# go to edit the menu and hover over the link. Look for the id# in the link.
Hope this helps.
Hey - that does work!
I did a quick test - created a new menu (got the id# for it by hovering over edit link - 158 in my case)...
In my theme's page.tpl.php file, as a test, I swapped out an original menu:
print theme('links', $secondary_links, array('class' => 'links secondary_links'))
with a new one... I didn't create a variable, just called menu_primary_links where $secondary_links used to be... also, supplied my own class info (supportliving_links):
print theme('links', menu_primary_links(1, 158), array('class' => 'links supportliving_links'))
(and, after the test, I was able to display all three menus).
Can anyone suggest if (and if so, where) I should create a new variable for such a menu?
i.e.: myvar = menu_primary_links(1, 158);
Thanks,
bill
Create this in your
Create this in your template.php file:
should do the trick.
Yes - that did the trick
Thanks...
In Summary - To add additional menus beyond primary and secondary:
Hello ebsqart This code
Hello ebsqart
This code works for drupal 5.x?
thanks
Oskar
gestión del conocimiento y de la información con software libre
Is there a version of this solution for 6.x ?
As another post on here stated, the ability to get the Menu ID# doesn't work in 6.15 so I assume this is a 5.x solution. Working with the code in the above posts (from k.obrien) and it seems to work.
So does anyone know of a way to implement this complete solution in 6.x or is it an entirely different beast now?
Thanks
the 6.x way
For Drupal 6 you will use the machine-readable name you assigned to your new menu (so you need to remember it).
But you need to add 'menu-' in front of it. So if your new menu's name is 'custom-menu' you'll have to use:
print theme('links', menu_navigation_links('menu-custom-name'));
see http://drupal.org/node/284255
Customizing secondary_links menu layout
If you want to create custom menu layout, you can use folowing code within page.tpl.php:
After that, you'll see contents of the array $secondary_links and will be able to create custom layout.