Printing an arbitrary menu just like primary_links and secondary_links
You can find out your menu name by going to admin/build/menu and hovering over it-- the name is a text string, separating the words in the menu title with dashes, and all lower case.
In your template.php
<?php
function agarictheme_preprocess_page(&$vars) {
$menu = menu_navigation_links("menu-name-here");
$vars['special_menu_name'] = theme('links', $menu);
}
?>
In page.tpl.php (or page-front.tpl.php or other variation)
<?php
print $special_menu_name;
?>
Note: this isn't working for us, when it should, and does when the menu code in the page template and printing directly is working.
This is what is working:
<?php
$menu = menu_navigation_links("menu-name-here");
print theme('links', $menu);
?>
Other new page variables are being passed successfully, so this is very weird.
Wait, do template variables need to be registered?
References
http://nicklewis.org/drupal-hackers-cookbook/menus/menu-navigation-links
http://api.drupal.org/api/function/theme_navigation_links/6
http://api.drupal.org/api/function/theme_menu_tree/6 (used to use this in Drupal 5, and the function is still there in Drupal 6, but it wants a menu numeric id)
Comments
It does work
In a Zen subtheme template.php this is working:
<?php
/**
* Override or insert variables into the page templates.
*
* @param $vars
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("page" in this case.)
*/
function zenjali_preprocess_page(&$vars, $hook) {
$menu = menu_navigation_links('menu-footer');
$vars['footer_links'] = theme('links', $menu);
}
?>
With the simple code below in page.tpl.php:
<?php
print $footer_links;
?>
Maybe I just forgot to flush my theme cache above!
Drupal Site
This helped out greatly, was straight to the point and easy to paste. Thanks!
Tutorial
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/
Multilingual
What about multilingual menus?
Post new comment