A module to have a drop down css/javascript menu for site navigation and admin navigation.

', array('!link' => l('admin/build/block', 'admin/build/block'))); break; } return $output; } /* * Settings form as implemented by hook_menu */ function yuimenu_admin_settings() { $form['yuimenu_root'] = array( '#type' => 'select', '#title' => t('Source Menu Tree'), '#description' => t('The menu tree from which to show a nice menu.'), '#default_value' => variable_get('yuimenu_root','1'), '#options' => menu_parent_options(0), ); $form['yuimenu_type'] = array( '#type' => 'select', '#title' => t('Menu Display type'), '#description' => t('Select the display type of the menu.'), '#default_value' => variable_get('yuimenu_type','tna'), '#options' => array('tns' =>'Website Top Nav With Submenus From JavaScript', 'tnm' =>'Website Top Nav With Submenus Built From Markup') ); $form['yuimenu_animate'] = array( '#type' => 'checkbox', '#title' => t('Animated Menu'), '#description' => t('To enable animation while opening menu check this.'), '#default_value' => variable_get('yuimenu_animate',0), ); return system_settings_form($form); } /** * Implemention of hook_menu(). */ function yuimenu_menu($may_cache) { if (!$may_cache) { drupal_set_html_head(' '); if (variable_get('yuimenu_animate',0)) { drupal_set_html_head(''); } switch (variable_get('yuimenu_type','tna')) { case 'tns': $script_body_to_html_head = get_yui_top_script(); break; case 'tnm': $script_body_to_html_head = get_yui_top_markup(); break; } drupal_set_html_head($script_body_to_html_head); drupal_add_js(drupal_get_path('module', 'yuimenu') .'/yuimenu.js'); } else { $items[] = array( 'path' => 'admin/settings/yuimenu', 'title' => t('YUI Menu Settings'), 'callback' => 'drupal_get_form', 'callback arguments' => 'yuimenu_admin_settings', 'access' => user_access('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); } return $items; } function get_yui_top_markup () { $scr = ' '; return ($scr); } function get_yui_top_script () { $scr = ''; return ($scr); } /* * when menu has a " or ' the script is fails. So replace them. */ function rep_char ($inStr) { $fromChar= array("\"","\\"); $toChar = array("'","-"); $outStr = str_replace($fromChar, $toChar, $inStr); return ($outStr); //return t($inStr); } function html_menu($pid = 1) { switch (variable_get('yuimenu_type','tna')) { case 'tns' : $output = get_html_menu_script($pid); break; case 'tnm' : $output = get_html_menu_markup($pid); break; } return $output; } function get_html_menu_script ($pid) { $menu = menu_get_menu(); $output .='
'; return $output; } function get_html_menu_markup ($pid) { $menu = menu_get_menu(); $output .='
    '; if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { if (count($menu['visible'][$pid]['children']) > 0) { $output .= compose_markap_body($pid); } } $output .='
'; return $output; } function compose_markap_body ($pid) { $menu = menu_get_menu(); if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { foreach ($menu['visible'][$pid]['children'] as $mid) { if (count($menu['visible'][$mid]['children']) > 0) { if (is_menu_child_of_root($mid)) { $output .= "
  • ".l($menu['visible'][$mid]['title'],$menu['visible'][$mid]['path'],array('class'=>'yuimenubaritemlabel')); } else { $output .= "
  • ".l($menu['visible'][$mid]['title'],$menu['visible'][$mid]['path'],array('class'=>'yuimenuitemlabel')); } $output .= '
      '; $output .= compose_markap_body($mid); $output .= '
  • '; } else { if (is_menu_child_of_root($mid)) { $output .= "
  • ".l($menu['visible'][$mid]['title'],$menu['visible'][$mid]['path'],array('class'=>'yuimenubaritemlabel'))."
  • "; } else { $output .= "
  • ".l($menu['visible'][$mid]['title'],$menu['visible'][$mid]['path'],array('class'=>'yuimenuitemlabel'))."
  • "; } } } } return ($output); } function is_menu_child_of_root ($pid) { $menu = menu_get_menu(); $is_menu_child = false; $myroot = variable_get('yuimenu_root','1'); foreach ($menu['visible'][$myroot]['children'] as $root_child) { if ($root_child == $pid) $is_menu_child= true; } return ($is_menu_child); } function script_menu($pid = 1) { $menu = menu_get_menu(); if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { $i=0; foreach ($menu['visible'][$pid]['children'] as $mid) { if (count($menu['visible'][$mid]['children'])>0) { $output .= "this.getItem(". $i++ .").cfg.setProperty(\"submenu\", { id: \"".rep_char($menu['visible'][$mid]['title'])."\", itemdata: oSubmenuData[\"".rep_char($menu['visible'][$mid]['title'])."\"] });\n"; } } } return $output; } function create_menu($pid = 1) { $menu = menu_get_menu(); $i=1; if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { foreach ($menu['visible'][$pid]['children'] as $mid) { $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL; $output .= "\n\"" . rep_char($menu['visible'][$mid]['title']) . "\": [\n"; if (count($children) > 0) { $output .= create_inner_menu($mid); } if ($i 0) { $output .= "{ text: \"".rep_char($menu['visible'][$mid]['title'])."\", submenu: { id: \"".url(rep_char($menu['visible'][$mid]['path']))."\", itemdata: [\n"; $output .= create_inner_menu($mid); $output .= "]}}"; } else { $output .= "{ text: \"".rep_char($menu['visible'][$mid]['title'])."\", url: \"".url(rep_char($menu['visible'][$mid]['path']))."\" }\n"; } if ($j