Projet

Général

Profil

Paste
Télécharger (1,83 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / bootstrap / theme / menu / menu-link.func.php @ 87dbc3bf

1
<?php
2
/**
3
 * @file
4
 * menu-link.func.php
5
 */
6

    
7
/**
8
 * Overrides theme_menu_link().
9
 */
10
function bootstrap_menu_link(array $variables) {
11
  $element = $variables['element'];
12
  $sub_menu = '';
13

    
14
  if ($element['#below']) {
15
    // Prevent dropdown functions from being added to management menu so it
16
    // does not affect the navbar module.
17
    if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {
18
      $sub_menu = drupal_render($element['#below']);
19
    }
20
    elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] == 1)) {
21
      // Add our own wrapper.
22
      unset($element['#below']['#theme_wrappers']);
23
      $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';
24
      // Generate as standard dropdown.
25
      $element['#title'] .= ' <span class="caret"></span>';
26
      $element['#attributes']['class'][] = 'dropdown';
27
      $element['#localized_options']['html'] = TRUE;
28

    
29
      // Set dropdown trigger element to # to prevent inadvertant page loading
30
      // when a submenu link is clicked.
31
      $element['#localized_options']['attributes']['data-target'] = '#';
32
      $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
33
      $element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
34
    }
35
  }
36
  // On primary navigation menu, class 'active' is not set on active menu item.
37
  // @see https://drupal.org/node/1896674
38
  if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
39
    $element['#attributes']['class'][] = 'active';
40
  }
41
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
42
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
43
}