Show all nested menu links in Drupal 7 How do I display all nested links in &lt;ul&gt;&lt;li&gt; format in Drupal 7? The default code only displays the 1st level links even though they are arranged in the Drupal admin menu as nested:

&lt;?php if ($main_menu): ?&gt;
&lt;div id="mainmenu"&gt; &lt;?php print theme( 'links__system_main_menu', array('links' =&gt; $main_menu) ); ?&gt; &lt;/div&gt;
&lt;?php endif; ?&gt;


Only the 1st level is displayed in the ff. menu setup:

-Fruits
---Apples
---Oranges
---Lemons
-Cars
---Big car
---Small car
---Fucked up car
-Whatever
The default $main_menu variable in page.tpl.php is set to menu_main_menu(), which is a contextual view of the main menu tree. 

To get your desired output, you need to get the entire menu tree using menu_tree_all_data() and menu_tree_output().

To do this in your theme, create template.php if you haven't already, and add a new preprocess function for the page template:

function THEMENAME_preprocess_page(&amp;$variables) {
  // Get the entire main menu tree
  $main_menu_tree = menu_tree_all_data('main-menu');

  // Add the rendered output to the $main_menu_expanded variable
  $variables['main_menu_expanded'] = menu_tree_output($main_menu_tree);
}


Then, in page.tpl.php, you can just use:

&lt;?php print render($main_menu_expanded); ?&gt; 


to get a expanded, nested unordered list of the main menu.

For a little more flexibility, you might want to consider the Menu Block module, which will let you create blocks of expanded menus out of the box with its Expand all children of this tree option as well as a host of other options for segmenting menu trees.