menu_attributes.api.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @file
  4. * Documentation for Menu Attributes API.
  5. */
  6. /**
  7. * Inform the menu_attributes module about custom attributes.
  8. *
  9. * @return
  10. * An array of attributes to be controlled by Menu Attributes, keyed by
  11. * attribute name. Each attribute record should be an array with the following
  12. * key/value pairs:
  13. * - label: The human-readable name of the attribute.
  14. * - description: The attribute description.
  15. * - form: A Form API array. Some default values for this array are provided
  16. * in menu_attributes_get_menu_attribute_info().
  17. * - scope: An array of scope options, MENU_ATTRIBUTES_LINK or
  18. * MENU_ATTRIBUTES_ITEM or both. If no scope is provided, both will
  19. * be assumed.
  20. *
  21. * @see menu_attributes_menu_attribute_info()
  22. * @see menu_attributes_get_menu_attribute_info()
  23. */
  24. function hook_menu_attribute_info() {
  25. // Add a Tabindex attribute.
  26. $info['tabindex'] = array(
  27. 'label' => t('Tabindex'),
  28. 'description' => t('Specifies the tab order for the link.'),
  29. 'form' => array(
  30. '#maxlength' => 3,
  31. '#size' => 2,
  32. ),
  33. 'scope' => array(MENU_ATTRIBUTES_LINK),
  34. );
  35. return $info;
  36. }
  37. /**
  38. * Alter the list of menu item attributes.
  39. *
  40. * @param $attributes
  41. * An array of attributes to be controlled by Menu Attributes, keyed by
  42. * attribute name.
  43. *
  44. * @see hook_menu_attribute_info()
  45. * @see menu_attributes_get_menu_attribute_info()
  46. */
  47. function hook_menu_attribute_info_alter(array &$attributes) {
  48. // Remove the Access Key attribute.
  49. unset($attributes['accesskey']);
  50. }