'select', '#title' => t('Select the menu to list'), '#default_value' => variable_get('jquery_drawer', 'navigation:0'), '#options' => menu_parent_options(menu_get_menus(), 0), ); return $form; case 'save': variable_set('jquery_drawer', $edit['jquery_drawer']); break; case 'view': $menu = explode(':', variable_get('jquery_drawer', 'navigation:0')); $block['content'] = theme('jquery_drawer', $menu[0], $menu[1]); return $block; } } /** * Implementation of hook_theme(); */ function jquery_drawer_theme() { return array( 'jquery_drawer' => array( 'arguments' => array( 'menu' => NULL, 'parent' => NULL, ), ), 'jquery_drawer_javascript' => array( 'arguments' => array(), ), 'jquery_drawer_css' => array( 'arguments' => array(), ), 'jquery_drawer_link' => array( 'arguments' => array(), ), ); } /** * Generate the menu. */ function theme_jquery_drawer($menu_name, $mlid) { $item_class = "jquery-drawer-menu-item"; $sub_item_class = "jquery-drawer-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 = jquery_drawer_build($menu); $output .= ''; // TODO: remove this $output .= '