Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Created April 24, 2012 19:49
Show Gist options
  • Select an option

  • Save wrburgess/2483094 to your computer and use it in GitHub Desktop.

Select an option

Save wrburgess/2483094 to your computer and use it in GitHub Desktop.
Inserting Main Menu and Secondary Menus in templates on Drupal 7

Inserting Main Menu and Secondary Menus in templates on Drupal 7

References

Setup

  • Go to the Structure > Menu > Settings
  • Choose Main Menu as the Source for the Secondary links

Scripts

Paste this script into your template (tpl) file:

<ul class="main-menu">
  <?php print 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'),
    ),
  )); ?>
</ul>

Past this script into a region/space on your template (tpl) file:

    <ul>
      <?php print theme('links__system_main_menu', array(
        'links' => $secondary_menu,
        'attributes' => array(
          'id' => 'seconday-menu-links',
          'class' => array('links', 'clearfix'),
        ),
        'heading' => array(
          'text' => t('Secondary menu'),
          'level' => 'h2',
          'class' => array('element-invisible'),
        ),
      )); ?>
    </ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment