Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.84 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  2.   $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  3.   if (!empty($extra_class)) {
  4.     $class .= ' '. $extra_class;
  5.   }
  6.  
  7.   $link_array = explode('href="', $link);
  8.   $link_array = explode('"', $link_array[1]);
  9.   $link_path = trim($link_array[0], '/');
  10.   $current_path = drupal_get_path_alias($_GET['q']);
  11.    
  12.   if (substr($current_path, 0, strlen($link_path)) == $link_path) {
  13.     $in_active_trail = TRUE;
  14.   }
  15.  
  16.   if ($in_active_trail) {
  17.     $class .= ' active active-trail';
  18.     @preg_match('/class="([^"]*)"/i', $link, $matches);
  19.     if (count($matches) < 1) {
  20.       $link = preg_replace('/ef="([^"]*)"/i', "href=\"$1\" class=\"active\"", $link);
  21.     }
  22.   }
  23.   return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
  24. }
  25. ?>