User login

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)

Resolution

Searched words: 
print another menu like primary or secondary lists drupal 6 drupal 6 print menu load and output a menu

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

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.