Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save adrianodias8/5a2df2c981a99ae09beb9f45016db045 to your computer and use it in GitHub Desktop.

Select an option

Save adrianodias8/5a2df2c981a99ae09beb9f45016db045 to your computer and use it in GitHub Desktop.
cnt_description_pathauto_alias_alter
<?php
/**
* Implements hook_pathauto_pattern_alter().
*/
function cnt_description_pathauto_alias_alter(&$alias, array &$context) {
if ($context['module'] == 'node' && ($context['bundle'] == 'cnt_description')) {
$exploded_alias = explode('/',substr($alias, 1));
$exploded_alias[0] = preg_replace([
'/policy/',
'/page/',
'/activity/'
], [
'policies',
'pages',
'activities'
],
$exploded_alias[0], 1,);
$alias = '/'.implode('/',$exploded_alias);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment