Very new to Drupal--trying to understand building a dynamic navigation menu for end users to handle. Is it possible to print the Main Menu inside a block I'm using for the header? e.g.

<nav id="main-menu" role="navigation" tabindex="-1">
      print theme('links__system_main_menu', array(
        'links' => $main_menu,
        'attributes' => array(
          'class' => array('links', 'inline', 'clearfix'),
        'heading' => array(
          'text' => t('Main menu'),
          'level' => 'h2',
          'class' => array('element-invisible'),
      )); ?>

Pages render the <nav> tag, but nothing inside such as the content (basic pages) that Main Menu definitely contains so far as I can see in /admin/structure/menu/manage/main-menu.

I'm using my own sub-theme (derived from Zen, but most regions removed,) so I've been trying the code above (and variations) in a block added to the Header region. Is this not the Drupal convention?

2 Answers 2


In a custom zen sub-theme I currently use the following code:

$menu = menu_navigation_links('main-menu');
print theme('links__main-menu', array('links' => $menu, 'attributes' => array('class'=> 'menu')));

This is appliable to any manu – just change the name accordingly. And it's easiely printable wherever I need it (page.tpl.php). It prints a `ul´ like this:

<ul class="menu">
    <li class="menu-966 first"><a href="http://...">Link 1</a></li>
    <li class="menu-959"><a href="…">Link 2</a></li>
    <li class="menu-967 last"><a href="http://.…">Link 3</a></li>

An alternative solution is to use the menu block module, which lets you easily configure as many different menu blocks as you like.

It gives many options in regards to which menu to use for a block and which levels of that menu to display.

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.