This is a simple module that enables the site to have drop down css/javascript menus for site navigation and admin navigation.
Remember to activate and configure the menus in !link
', array('!link' => l('admin/build/block', 'admin/build/block'))); break; } return $output; } /* * Implementation of hook_form_alter(). */ function nice_menus_form_alter($form_id, &$form) { switch ($form_id) { case 'system_theme_settings': // This is a global setting, so only insert the field on the global settings page. if (arg(4)) { return; } // Have to add a custom submit handler since this form doesn't use the standard system // submit handler. $form['#submit'] += array('nice_menus_system_theme_settings_submit' => array()); // Add global theme setting for a custom CSS file. $form['nice_menus_custom_css'] = array( '#type' => 'textfield', '#title' => t('Path to custom nice menus CSS file'), '#description' => t('To override the default nice menus CSS layout, enter the path to your custom CSS file (should be a relative path from the root of your Drupal install.'), '#default_value' => variable_get('nice_menus_custom_css', ''), '#weight' => 0, // Field appears below submit buttons w/o this -- yucky. ); break; } } /** * Records the nice menu custom CSS file per theme. */ function nice_menus_system_theme_settings_submit($form_id, $form_values) { variable_set('nice_menus_custom_css', $form_values['nice_menus_custom_css']); } /** * Implemention of hook_menu(). */ function nice_menus_menu($may_cache) { if (!$may_cache) { // Won't add if already added, but need this *before* our js // drupal_add_js('misc/drupal.js', 'core'); // We only want to include the JS for IE, not browsers capable of doing everything in css // We have to put all the js in drupal_set_html_head so they get called in the right order. drupal_set_html_head(''); //drupal_add_js(drupal_get_path('module', 'nice_menus') .'/nice_menus.js'); // Add main CSS functionality. drupal_add_css(drupal_get_path('module', 'nice_menus') .'/nice_menus.css'); // Add custom CSS layout if specified. if ($custom = variable_get('nice_menus_custom_css', '')) { drupal_add_css($custom); } // Fall back to default layout. else { drupal_add_css(drupal_get_path('module', 'nice_menus') .'/nice_menus_default.css'); } } else { $items[] = array( 'path' => 'admin/settings/nice_menus', 'title' => t('Nice Menus'), 'description' => t('Configure Nice Menus.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('nice_menus_admin_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); } return $items; } /* * Settings form as implemented by hook_menu */ function nice_menus_admin_settings() { $form['nice_menus_number'] = array( '#type' => 'select', '#title' => t('Number of Nice Menus'), '#description' => t('The total number of independent nice menus (blocks) you want.'), '#default_value' => variable_get('nice_menus_number', '2'), '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), ); return system_settings_form($form); } /* * Implementation of hook_block(). */ function nice_menus_block($op = 'list', $delta = 0, $edit = array()) { global $user; switch ($op) { case 'list': for ($i=1; $i <= variable_get('nice_menus_number', '2'); $i++) { $blocks[$i]['info'] = variable_get('nice_menus_name_'. $i, 'Nice Menu '. $i) .' (Nice Menu)'; } return $blocks; break; case 'configure': $form['nice_menus_name_'. $delta] = array( '#type' => 'textfield', '#title' => t('Menu Name'), '#default_value' => variable_get('nice_menus_name_'. $delta, 'Nice Menu '. $delta), ); $form['nice_menus_menu_'. $delta] = array( '#type' => 'select', '#title' => t('Source Menu Tree'), '#description' => t('The menu tree from which to show a nice menu.'), '#default_value' => variable_get('nice_menus_menu_'. $delta, '1'), '#options' => menu_parent_options(0), ); $form['nice_menus_type_'. $delta] = array( '#type' => 'select', '#title' => t('Menu Style'), '#description' => t('right: menu items are listed on top of each other and expand to the right') .'