In development site. I am using sitemap page so i need to print the all main menu and submenu in that page. I am using this code, but it is not working.

$main_menu = menu_navigation_links('menu-main-page');
echo '<pre>main menu';print_r($main_menu);

How can I achieve it?

3 Answers 3


If you want to render the menu for sitemap purpose, better to use the "Sitemap" module

Configuration page from this link


You can see the below screen on configuration page,

enter image description here

Just check the menu, which you want to display in sitemap.

After this you can access your page with /sitemap url and you can see your menu there on that page.


if drupal 7 try this

 <?php print theme('links__system_main_menu', array(
    'links' => $main_menu,
 'attributes' => array(
     'id' => 'menu',
    'heading' => array(
  'text' => t('Main menu'),
     'level' => 'h2',
   'class' => array(

The following code works on Drupal 7.

$menu = menu_tree('main-menu');
$menuhtml = drupal_render($menu);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.