Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 772
mian ji Avatar asked Nov 18 '25 11:11

mian ji


1 Answers

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); ?>
like image 60
Mike Vranckx Avatar answered Nov 21 '25 10:11

Mike Vranckx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!