You are here

function menu_minipanels_preprocess_menu_link in Menu Minipanels 7.2

Implements hook_preprocess_menu_link().

Add integration with Nice Menus module, which uses theme('menu_link') to its menus and requires a class 'menuparent' on the LI element for proper sub-menu functionality.

File

./menu_minipanels.module, line 276
Menu MiniPanels provides a flexible "mega menu" solution for Drupal by allowing a minipanel to be associated with a Drupal menu item. When that menu item is hovered, the minipanel content will be shown using standard CSS :hover techniques…

Code

function menu_minipanels_preprocess_menu_link(&$vars) {

  // Ignore links sent through theme_menu_link without a related 'menu'.
  if (!isset($vars['menu']) || !is_array($vars['menu'])) {
    return;
  }
  foreach ($vars['menu'] as $key => &$menu_item) {

    // Only add the class if a minipanel is defined for the specified link.
    if ($menu_item['link']['mlid'] == $vars['element']['#original_link']['mlid']) {
      if (!empty($menu_item['link']['options']['minipanel'])) {

        // Only add the class on pages not excluded by menu_minipanels configs.
        if (!menu_minipanels_excluded_path()) {

          // Only add the class if it doesn't already exist.
          if (!in_array('menuparent', $vars['element']['#attributes']['class'])) {
            $vars['element']['#attributes']['class'][] = 'menuparent';
          }
        }
      }
    }
  }
}