I need to render the main menu within the admin section of my website. I am setting up a module to do this on a new page. I need to theme this menu custom for just the admin, and leave it as it typically would be on the front-end of the site.

How can do do this?

$menu = menu_tree_all_data('main-menu');
// ...customize template/output for this menu and render from my module... 

You can use one of these method.

Below method is used to print Main Menu in page.tpl.php file:

$main_menu = menu_navigation_links('main-menu');
$output = '<div id="main-menu" class="navigation">';
$output .= theme('links__system_main_menu', array(
    'links' => $main_menu,
    'attributes' => array(
      'id' => 'main-menu-links',
      'class' => array('links', 'clearfix'),
    'heading' => array(
      'text' => t('Main menu'),
      'level' => 'h2',
      'class' => array('element-invisible'),
$output .= '</div>';
print $output;

Or the example provided here:

$tree = menu_tree_all_data('main-menu');
print drupal_render(menu_tree_output($tree));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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