How to print a custom menu in Drupal 7?
31,406
Solution 1
Berdir answer is correct. Drupal 7 theme_links function also more vastly uses arrays. For example if you would like to add another class name to the so that it is you would code it like this:
<?php print theme('links', array('links' => menu_navigation_links('menu-site-menu'), 'attributes' => array('class'=> array('links', 'site-menu')) ));?>
Solution 2
theme() now recieves an array of arguments. For example:
<?php
print theme('links', array('links' => menu_navigation_links('menu-site-menu')));
?>
Related videos on Youtube
Author by
404error
Updated on July 09, 2022Comments
-
404error almost 2 years
I have created a menu in Drupal 7 and created links to pages under that menu.
I named my new menu "Site Menu"
In my page.tpl.php where I want my menu to appear I have put this in place:
<?php print theme('links', menu_navigation_links('menu-site-menu')); ?>
After I have cleared my cache and refreshed my page my menu doesn't appear.
I am stumped. Any help would be greatly appreciated.
-
404error about 13 yearsThank you for you response. Unfortunately it did not solve my problem. I will investigate a little more. Thanks again.
-
Berdir about 13 yearsWell, are you sure that your argument to menu_navigation_links() is correct and that it returns your menu? Try printing that directly with debug() or dpm() (if you have devel.module installed). See also api.drupal.org/api/drupal/modules--system--page.tpl.php/7/…, look for main-menu, that's how core is displaying the menu.