function hook_pathauto_pattern_alter in Pathauto 6.2
Same name and namespace in other branches
- 8 pathauto.api.php \hook_pathauto_pattern_alter()
- 7 pathauto.api.php \hook_pathauto_pattern_alter()
Alter the pattern to be used before an alias is generated by Pathauto.
Parameters
string $pattern: The alias pattern for Pathauto to pass to token_replace() to generate the URL alias.
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').
- '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.
1 invocation of hook_pathauto_pattern_alter()
- pathauto_create_alias in ./
pathauto.inc - Apply patterns to create an alias.
File
- ./
pathauto.api.php, line 34 - Documentation for pathauto API.
Code
function hook_pathauto_pattern_alter(&$pattern, array &$context) {
// Switch out any [mod-DATETOKEN] tokens with [DATETOKEN] on update.
if ($module == 'node' && $context['op'] == 'update') {
$pattern = preg_replace('/\\[mod-([^]]*)?\\]/', '[$1]', $pattern);
}
}