You are here

function hook_token_values_alter in Token 6

Alter replacement values for placeholder tokens.

Parameters

$replacements: An associative array of replacements returned by hook_token_values().

$context: The context in which hook_token_values() was called. An associative array with the following keys, which have the same meaning as the corresponding parameters of hook_token_values():

  • 'type'
  • 'object'
  • 'options'

See also

hook_token_values()

1 invocation of hook_token_values_alter()
token_get_values in ./token.module
Return a list of valid substitution tokens and their values for the specified type.

File

./token.api.php, line 86
Hooks provided by the token module.

Code

function hook_token_values_alter(&$replacements, $context) {
  if ($context['type'] == 'node' && !empty($context['object'])) {
    $node = $context['object'];
    if (isset($replacements['title-raw']) && !empty($node->field_title[0]['value'])) {
      $title = $node->field_title[0]['value'];
      $replacements['title-raw'] = $title;
      $replacements['title'] = check_plain($title);
    }
  }
}