$menu_tree = menu_tree_all_data('main-menu'); // get the main menu tree $custom_menu = array(); // initialize a new menu array foreach ($menu_tree as $item) { if ($item['link']['hidden'] == 0) { // check if menu item is not hidden $custom_menu[$item['link']['menu_name']][$item['link']['mlid']] = array( 'title' => $item['link']['link_title'], 'href' => $item['link']['link_path'], 'children' => $item['below'], // add sub-menu items if exist ); } } print theme('links__custom_menu', array('links' => $custom_menu)); // print the custom menu
function mymodule_menu_tree__main_menu(&$variables) { $menu_tree = $variables['tree']; $menu_tree_output = ''; foreach ($menu_tree as $item) { $menu_tree_output .= '