Skip to content

Instantly share code, notes, and snippets.

@mattfarina
Created May 16, 2011 17:20
Show Gist options
  • Save mattfarina/974898 to your computer and use it in GitHub Desktop.
Save mattfarina/974898 to your computer and use it in GitHub Desktop.
Strip tags from pathauto node title
function custom_tokens_alter(array &$replacements, array $context) {
$options = $context['options'];
$sanitize = !empty($options['sanitize']);
if ($context['type'] == 'node' && !empty($context['data']['node'])) {
$node = $context['data']['node'];
foreach ($context['tokens'] as $name => $original) {
switch ($name) {
case 'title':
$title = !empty($options['pathauto']) ? strip_tags($node->title) : $node->title;
$replacements[$original] = $sanitize ? check_plain($title) : $title;
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment