How do I render sub-menus? I have a Drupal 7 installation that, for the purposes of this question, has just the core modules.

Using the Structure->Menus->Main Menu form, I added some items to the menu and, using a Mytheme_links__system_main_menu($main_menu) in the template file, dumped the menu items using print_r, just to check what is being passed through.

So far so good.

Now, in the Structure->Menus->Main Menu form, I add some child items beneath one of the top level items by dragging these items to the right one space under the parent. Then I clicked "Show as expanded" on the parent item and saved the configuration.

When I dump the $main_menu variable again, only the parent items are shown. The child items are never shown.

Can anyone help me understand how to ensure that the child items are rendered to the $main_menu array?

I don't really want to add pre-themed menu modules as there is a very simple but very specific layout that I need to achieve. Can the default Drupal menu module handle sub-menu items?
It may be caused by the "Show as expanded" unchecked checkbox by default on your menu items edition page. Check 'admin/structure/menu/item/{mid}/edit'



By the way, devel's module dpm(object) function is the Drupal way of print_r / var_dump inspecting things.