mian ji
mian ji

Reputation: 297

Drupal 7 not showing sub menu

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.

Upvotes: 3

Views: 5116

Answers (1)

Mike Vranckx
Mike Vranckx

Reputation: 5577

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); ?>

Upvotes: 5

Related Questions