A module to have a css/javascript based drop down and javascript based pop-up menu for site 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('Root of Menu Tree'), '#description' => t('Select the root item of menu tree.'), '#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', 'lns' =>'Website Left Nav With Submenus From JavaScript') ); $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) { $yui_source = variable_get('yui_source','http://yui.yahooapis.com/2.3.0'); // the order of script and style sheet is important. Don't change. yui_add_js('menu', $yui_source, '/build/yahoo-dom-event/yahoo-dom-event.js'); if (variable_get('yuimenu_animate',0)) { yui_add_js('menu', $yui_source, '/build/animation/animation-min.js'); } yui_add_css('menu', $yui_source, '/build/menu/assets/skins/sam/menu.css'); yui_add_js('menu', $yui_source, '/build/container/container_core-min.js'); yui_add_js('menu', $yui_source, '/build/menu/menu-min.js'); switch (variable_get('yuimenu_type','tns')) { case 'tns': $script_body_to_html_head = get_yui_top_script(); break; case 'tnm': $script_body_to_html_head = get_yui_top_markup(); break; case 'lns': $script_body_to_html_head = get_yui_left_script(); break; } drupal_set_html_head($script_body_to_html_head); drupal_add_css(drupal_get_path('module', 'yuimenu') .'/yuimenu.css'); } 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','tns')) { case 'tns' : $output = get_html_menu_script($pid); break; case 'lns' : $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) { //modification here: $my_menu_temp=menu_get_item($mid); $my_menu_link=$my_menu_temp['path']; $my_menu_title=$my_menu_temp['title']; 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')); //modification here: $output .= "
  • ".l($my_menu_title,$my_menu_link,array('class'=>'yuimenubaritemlabel')); } else { //$output .= "
  • ".l($menu['visible'][$mid]['title'],$menu['visible'][$mid]['path'],array('class'=>'yuimenuitemlabel')); //modification here: $output .= "
  • ".l($my_menu_title,$my_menu_link,array('class'=>'yuimenuitemlabel')); } /*$output .= '
      '; */ //modification here: //$output .= '
      $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'))."
    • "; //modification here: $output .= "
    • ".l($my_menu_title,$my_menu_link,array('class'=>'yuimenubaritemlabel'))."
    • "; } else { //$output .= "
    • ".l($menu['visible'][$mid]['title'],$menu['visible'][$mid]['path'],array('class'=>'yuimenuitemlabel'))."
    • "; //modification here: $output .= "
    • ".l($my_menu_title,$my_menu_link,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"; } $i++; } } 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'])."\",url: \"".url(rep_char($menu['visible'][$mid]['path']))."\", 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 ($jname; $block['content'] = $block_content; return $block; } } } function get_yui_left_script () { $scr = ''; return ($scr); }