
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.84 KB | hits: 11 | expires: Never
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
if (!empty($extra_class)) {
$class .= ' '. $extra_class;
}
$link_array = explode('href="', $link);
$link_array = explode('"', $link_array[1]);
$link_path = trim($link_array[0], '/');
$current_path = drupal_get_path_alias($_GET['q']);
if (substr($current_path, 0, strlen($link_path)) == $link_path) {
$in_active_trail = TRUE;
}
if ($in_active_trail) {
$class .= ' active active-trail';
@preg_match('/class="([^"]*)"/i', $link, $matches);
if (count($matches) < 1) {
$link = preg_replace('/ef="([^"]*)"/i', "href=\"$1\" class=\"active\"", $link);
}
}
return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
}
?>