You are here

function hook_pathauto_alias_alter in Pathauto 7

Same name and namespace in other branches
  1. 8 pathauto.api.php \hook_pathauto_alias_alter()
  2. 6.2 pathauto.api.php \hook_pathauto_alias_alter()
  3. 6 pathauto.api.php \hook_pathauto_alias_alter()

Alter Pathauto-generated aliases before saving.

Parameters

string $alias: The automatic alias after token replacement and strings cleaned.

array $context: An associative array of additional options, with the following elements:

  • 'module': The module or entity type being aliased.
  • 'op': A string with the operation being performed on the object being aliased. Can be either 'insert', 'update', 'return', or 'bulkupdate'.
  • 'source': A string of the source path for the alias (e.g. 'node/1'). This can be altered by reference.
  • 'data': An array of keyed objects to pass to token_replace().
  • 'type': The sub-type or bundle of the object being aliased.
  • 'language': A string of the language code for the alias (e.g. 'en'). This can be altered by reference.
  • 'pattern': A string of the pattern used for aliasing the object.
1 invocation of hook_pathauto_alias_alter()
pathauto_create_alias in ./pathauto.inc
Apply patterns to create an alias.

File

./pathauto.api.php, line 189
Documentation for pathauto API.

Code

function hook_pathauto_alias_alter(&$alias, array &$context) {

  // Add a suffix so that all aliases get saved as 'content/my-title.html'
  $alias .= '.html';

  // Force all aliases to be saved as language neutral.
  $context['language'] = LANGUAGE_NONE;
}