pathauto.api.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @file
  4. * Documentation for pathauto API.
  5. *
  6. * @see hook_token_info
  7. * @see hook_tokens
  8. */
  9. function hook_path_alias_types() {
  10. }
  11. function hook_pathauto($op) {
  12. }
  13. /**
  14. * Alter Pathauto-generated aliases before saving.
  15. *
  16. * @param string $alias
  17. * The automatic alias after token replacement and strings cleaned.
  18. * @param array $context
  19. * An associative array of additional options, with the following elements:
  20. * - 'module': The module or entity type being aliased.
  21. * - 'op': A string with the operation being performed on the object being
  22. * aliased. Can be either 'insert', 'update', 'return', or 'bulkupdate'.
  23. * - 'source': A string of the source path for the alias (e.g. 'node/1').
  24. * This can be altered by reference.
  25. * - 'data': An array of keyed objects to pass to token_replace().
  26. * - 'type': The sub-type or bundle of the object being aliased.
  27. * - 'language': A string of the language code for the alias (e.g. 'en').
  28. * This can be altered by reference.
  29. * - 'pattern': A string of the pattern used for aliasing the object.
  30. */
  31. function hook_pathauto_alias_alter(&$alias, array &$context) {
  32. // Add a suffix so that all aliases get saved as 'content/my-title.html'
  33. $alias .= '.html';
  34. // Force all aliases to be saved as language neutral.
  35. $context['language'] = LANGUAGE_NONE;
  36. }
  37. /**
  38. * Alter the list of punctuation characters for Pathauto control.
  39. *
  40. * @param $punctuation
  41. * An array of punctuation to be controlled by Pathauto during replacement
  42. * keyed by punctuation name. Each punctuation record should be an array
  43. * with the following key/value pairs:
  44. * - value: The raw value of the punctuation mark.
  45. * - name: The human-readable name of the punctuation mark. This must be
  46. * translated using t() already.
  47. */
  48. function hook_pathauto_punctuation_chars_alter(array &$punctuation) {
  49. // Add the trademark symbol.
  50. $punctuation['trademark'] = array('value' => '™', 'name' => t('Trademark symbol'));
  51. // Remove the dollar sign.
  52. unset($punctuation['dollar']);
  53. }