'select', '#title' => t('Select the menu to list'), '#default_value' => variable_get('finder_menu', 'navigation:0'), '#options' => menu_parent_options(menu_get_menus(), 0), ); return $form; case 'save': variable_set('finder_menu', $edit['finder_menu']); break; case 'view': $menu = explode(':', variable_get('finder_menu', 'navigation:0')); $block['content'] = theme('finder_menu', $menu[0], $menu[1]); return $block; } } /** * Implementation of hook_theme(); */ function finder_menu_theme() { return array( 'finder_menu' => array( 'arguments' => array( 'menu' => NULL, 'parent' => NULL, ), ), ); } /** * Generate the menu. */ function theme_finder_menu($menu_name, $mlid) { $item_class = "finder-menu-menu-item"; $sub_item_class = "finder-menu-sub-menu-item"; // Find menu item in the menu tree $menu_tree = menu_tree_all_data($menu_name); $menu_link = menu_link_load($mlid); if ($mlid != 0) { for ($i=1; $i<10; $i++) { foreach ($menu_tree as $menu_item) { if ($menu_item["link"]['mlid'] == $mlid) { $menu = $menu_item['below']; break 2; } else { if ($menu_item["link"]['mlid'] == $menu_link['p'. $i]) { $menu_tree = $menu_item['below']; break; } } } } } else { $menu = $menu_tree; } // Don't display anything if the selected menu has no children if (!$menu) { return; } // Backup active menu trail and set a new one $active_menu_name = menu_get_active_menu_name(); menu_set_active_menu_name($menu_name); // Build table of mlid in the active trail foreach (menu_set_active_trail() as $value) { if ($value['mlid']) { $trail[] = $value['mlid']; } } // Restore active menu trail menu_set_active_menu_name($active_menu_name); // Build the menus $output = '