Guest User

Untitled

a guest
Feb 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  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. ?>
Add Comment
Please, Sign In to add comment