simplemenu_inactive_parents.module 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // $Id$
  3. /**
  4. * @file
  5. * Make all the simplemenu parent menu items non-clickable.
  6. */
  7. /**
  8. * \brief Alter the menu item link theme registry.
  9. *
  10. * This function grabs the simplemenu theme registry for the
  11. * menu_item_link theming. This gives us a way to remove the
  12. * link and replace it with a name (anchor) instead.
  13. *
  14. * This is only applied to the Simplemenu as intefering with
  15. * other menus could have unwanted side effects.
  16. *
  17. * \note
  18. * This is called at the time the theme registry is built.
  19. * It is then put in the cache until next time the registry
  20. * is built by the system (i.e. caches are cleared by user,
  21. * because a module is installed, etc.)
  22. */
  23. function simplemenu_theme_registry_alter(&$theme_registry) {
  24. global $theme;
  25. // Save theme function
  26. $themes = variable_get('simplemenu_theme_function', array());
  27. $themes[$theme] = $theme_registry['menu_item_link']['function'];
  28. variable_set('simplemenu_theme_function', $themes);
  29. // Replace with our own
  30. $theme_registry['menu_item_link']['function'] = 'simplemenu_theme_menu_item_link';
  31. }
  32. /**
  33. * \brief Transform the menu item link.
  34. *
  35. * This function intercepts the menu item link theming function of
  36. * the system and
  37. */
  38. function simplemenu_theme_menu_item_link($link) {
  39. global $theme;
  40. // this is a drop down?
  41. if (!empty($link['has_children']) && variable_get('simplemenu_running', FALSE)) {
  42. return '<a name="menu-id-' . $link['mlid'] . '">' . $link['title'] . '</a>';
  43. }
  44. // got a theme function?
  45. $themes = variable_get('simplemenu_theme_function', array());
  46. if (isset($themes[$theme])) {
  47. return $themes[$theme]($link);
  48. }
  49. // somehow the preprocess function did not get called?!
  50. // use the core default
  51. return theme_menu_item_link($link);
  52. }
  53. // vim: ts=2 sw=2 et syntax=php