3

How can I custom the output menu like stack in drupal 7. The main menu link appear above and the sub-menu link appear below, or some menu styles like this.

In Bartik theme, the $main_menu variable only content primary menu information but no child. So I must custom this variable or do something else to solve my problem ? Here is what i said:

<div id="main-menu" class="navigation">
    <?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'),
      ),
    )); ?>
  </div> <!-- /#main-menu -->
Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
Kevin
  • 1,403
  • 4
  • 18
  • 34

1 Answers1

2

You can use drupal's standard menu output with parent menu items and sub menu items, then customize the appearance to your liking using CSS and javaScript.

You can benefit from the fact of that the sub menu items will appear ONLY for an active parent.

Just make sure that Mark as expanded for ALL parent menu items is checked off so they don't show by default.

Update:

Don't print out the menu in the template file. Instead, create a region in the same position then install menu block module.

This way is more flexible than yours and gives you more options to control your menu (like the depth of sub items).

Check the module documentation for more details. Configuring menu blocks section.

Hope this helps... Muhammad.

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
  • Please give me more information, what function I need to customise the menu output? Where should I do it, in my module or in my theme folder? – Kevin Nov 01 '12 at 09:18
  • I've update my answer. Let me know if you still can't get it to work. – Muhammad Reda Nov 01 '12 at 09:28