materio-base-legacy/simplemenu_inactive_parents.module
Alexis Wilke d9f856a075 Pretty major update to better support several options:
* Added a white border at the top of the drop-downs in original
* Optimized the "view" test for simplemenu
* Enhanced the init() function by creating sub-functions and
  moving the footer functionality in it
* The list of themes is now dynamically generated from the
  simplemenu themes folder
* The list of superfish now includes a 'custom' so the code may
  come from another module or theme
* The Simplemenu variable can now be moved to the header and
  cache in its own JS file
* Create a Devel and Inactive Parents modules for additional
  functionality
* Moved the simplemenu modules in the Menu package
* Changed the function generating the menu so other modules may
  tweak the menu if so they wish
* Moved the support for Devel in a separate sub-module.
  (this is with the new way of doing things & has a corresponding
  update hook to tell users about the change. It is actually a good
  example of using the new hook system!)
2010-05-16 09:10:28 +00:00

63 lines
1.8 KiB
PHP

<?php
// $Id$
/**
* @file
* Make all the simplemenu parent menu items non-clickable.
*/
/**
* \brief Alter the menu item link theme registry.
*
* This function grabs the simplemenu theme registry for the
* menu_item_link theming. This gives us a way to remove the
* link and replace it with a name (anchor) instead.
*
* This is only applied to the Simplemenu as intefering with
* other menus could have unwanted side effects.
*
* \note
* This is called at the time the theme registry is built.
* It is then put in the cache until next time the registry
* is built by the system (i.e. caches are cleared by user,
* because a module is installed, etc.)
*/
function simplemenu_theme_registry_alter(&$theme_registry) {
global $theme;
// Save theme function
$themes = variable_get('simplemenu_theme_function', array());
$themes[$theme] = $theme_registry['menu_item_link']['function'];
variable_set('simplemenu_theme_function', $themes);
// Replace with our own
$theme_registry['menu_item_link']['function'] = 'simplemenu_theme_menu_item_link';
}
/**
* \brief Transform the menu item link.
*
* This function intercepts the menu item link theming function of
* the system and
*/
function simplemenu_theme_menu_item_link($link) {
global $theme;
// this is a drop down?
if (!empty($link['has_children']) && variable_get('simplemenu_running', FALSE)) {
return '<a name="menu-id-' . $link['mlid'] . '">' . $link['title'] . '</a>';
}
// got a theme function?
$themes = variable_get('simplemenu_theme_function', array());
if (isset($themes[$theme])) {
return $themes[$theme]($link);
}
// somehow the preprocess function did not get called?!
// use the core default
return theme_menu_item_link($link);
}
// vim: ts=2 sw=2 et syntax=php