function menu_minipanels_page_alter in Menu Minipanels 7.2
Same name and namespace in other branches
- 7 menu_minipanels.module \menu_minipanels_page_alter()
Implements hook_page_alter().
Determines whether the current page request contains any Menu MiniPanels and if so, add the required assets.
File
- ./
menu_minipanels.module, line 307 - 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_page_alter(&$page) {
// Optionally ignore certain pages.
if (menu_minipanels_excluded_path()) {
return;
}
// Add CSS.
// Load each of the menus that are configured for menu_minipanels. It is safe
// to use menu_get_names() here as the data is cached, and it won't be
// possible that the shortcut sets have been accidentally added.
$load_requirements = FALSE;
$enabled_menus = array();
foreach (menu_get_names() as $menu) {
if (variable_get('menu_minipanels_' . $menu . '_enabled', FALSE)) {
$enabled_menus[] = $menu;
// Loop through each level of the menu tree and see whether qTip needs to
// be loaded.
$level = 0;
while ($items = menu_navigation_links($menu, $level)) {
if (menu_minipanels_prepare_links($items)) {
$load_requirements = TRUE;
}
$level++;
}
}
}
// If the main menu is enabled and the main & secondary menus both point to
// the same menu, load the second level of that menu.
$primary_menu = variable_get('menu_main_links_source', 'main-menu');
$secondary_menu = variable_get('menu_secondary_links_source', 'user-menu');
if (in_array($primary_menu, $enabled_menus) && $primary_menu == $secondary_menu) {
if (menu_minipanels_prepare_links(menu_navigation_links($primary_menu, 1))) {
$load_requirements = TRUE;
}
}
// If menus are actually needed, load the required CSS.
if ($load_requirements) {
// The path to this module.
$path = drupal_get_path('module', 'menu_minipanels');
// Load the module's custom CSS.
drupal_add_css($path . '/css/menu_minipanels.css');
}
}