3

i am new to drupal and creating custom theme, i am using Main Menu but it is now showing sub-pages, i am using following code to show.

print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix', 'main-menu')))); 

Please let me know what to do ? thanks in advance.

mian ji
  • 297
  • 1
  • 8
  • 16

1 Answers1

5

Using this method will not render the sub items of a menu item. In order to have a menu with multiple levels you can either:

  • Use the available Main menu block available under admin/structure/block
  • Change the $main_menu variable passed to the template by using a preprocess function

In template.php of your theme:

function YOURTHEME_process_page(&$variables) {
    $menu_tree = menu_tree_all_data('main-menu');
    $variables['main_menu'] = menu_tree_output($menu_tree);
}

In your template file (page.tpl.php)

<?php print render($main_menu); ?>
Mike Vranckx
  • 5,557
  • 3
  • 25
  • 28