Altering Pathauto pattern

Note that this hook works only if the default pattern is set up for the entity that you’d like to alter.

admin/config/search/path/patterns
function hook_pathauto_pattern_alter(&$pattern, array $context) {
  if ($context['module'] == 'node' && $context['bundle'] == 'l_standard' && ($context['op'] == 'insert' or $context['op'] == 'update' or $context['op'] == 'bulkupdate')) {
    $pattern->setPattern('library/services/[node:title]');
  }
}

This allows for conditional statements where you can develop dynamic path patterns.

Leave a comment

Your email address will not be published. Required fields are marked *