function hook_token_values in Token 5
Same name and namespace in other branches
- 6 token.api.php \hook_token_values()
Provide replacement values for placeholder tokens.
Parameters
$type: The type of token being replaced (e.g. 'global', 'node', or 'user').
$data: (optional) An object to be used when generating replacement values.
$options: (optional) A associative array of options to control the token replacement process.
Return value
An associative array of replacement values, keyed by the original 'raw' tokens that were found in the source text. For example: $values['title-raw'] = 'My new node';
8 functions implement hook_token_values()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- book_token_values in ./
token_node.inc - Implementation of hook_token_values() for book nodes
- comment_token_values in ./
token_comment.inc - Implementation of hook_token_values().
- content_token_values in ./
token_cck.inc - node_token_values in ./
token_node.inc - Implementation of hook_token_values().
- taxonomy_token_values in ./
token_taxonomy.inc - Implementation of hook_token_values().
1 invocation of hook_token_values()
- 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 55 - Hooks provided by the token module.
Code
function hook_token_values($type, $object = NULL, $options = array()) {
$values = array();
if ($type == 'global') {
$values['random-number'] = mt_rand();
}
if ($type == 'node' && !empty($object)) {
$values['node-random-nid'] = mt_rand(1, $object->nid);
}
return $values;
}