Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.03 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Overrides theme_menu_link().
  4.  */
  5. function THEMENAME_menu_link(array $variables) {
  6.   $element = $variables['element'];
  7.   $sub_menu = '';
  8.  
  9.   if ($element['#below']) {
  10.     // Prevent dropdown functions from being added to management menu so it
  11.     // does not affect the navbar module.
  12.     if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {
  13.       $sub_menu = drupal_render($element['#below']);
  14.     }
  15.     //Here we need to change from ==1 to >=1 to allow for multilevel submenus
  16.     elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] >= 1)) {
  17.       // Add our own wrapper.
  18.       unset($element['#below']['#theme_wrappers']);
  19.       $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';
  20.       // Generate as standard dropdown.
  21.       //$element['#title'] .= ' <span class="caret"></span>'; Smartmenus plugin add's caret
  22.       $element['#attributes']['class'][] = 'dropdown';
  23.       $element['#localized_options']['html'] = TRUE;
  24.  
  25.       // Set dropdown trigger element to # to prevent inadvertant page loading
  26.       // when a submenu link is clicked.
  27.       $element['#localized_options']['attributes']['data-target'] = '#';
  28.       $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
  29.       //comment element bellow if you want your parent menu links to be "clickable"
  30.       //$element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
  31.     }
  32.   }
  33.   // On primary navigation menu, class 'active' is not set on active menu item.
  34.   // @see https://drupal.org/node/1896674
  35.   if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
  36.     $element['#attributes']['class'][] = 'active';
  37.   }
  38.   $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  39.   return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement