Created
May 16, 2011 17:20
-
-
Save mattfarina/974898 to your computer and use it in GitHub Desktop.
Strip tags from pathauto node title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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