function hook_token_list in Token 6
Same name and namespace in other branches
- 5 token.api.php \hook_token_list()
Provide metadata about available placeholder tokens and token types.
Parameters
$type: The type of tokens to list (e.g. 'global', 'node', or 'user'). To list all tokens, use 'all'.
Return value
An associative array of available tokens. The base array is keys of token types and an array of its tokens. The token arrays are keys containing the raw name of the token and values containing its user-friendly name.
9 functions implement hook_token_list()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- book_token_list in ./
token_node.inc - Implements hook_token_list() on behalf of book.module.
- comment_token_list in ./
token_comment.inc - Implements hook_token_list() on behalf of comment.module.
- menu_token_list in ./
token_node.inc - Implements hook_token_list() on behalf of menu.module.
- node_token_list in ./
token_node.inc - Implements hook_token_list() on behalf of node.module.
- taxonomy_token_list in ./
token_taxonomy.inc - Implements hook_token_list().
2 invocations of hook_token_list()
- token_find_duplicate_tokens in ./
token.module - Find tokens that have been declared twice by different modules.
- token_get_list in ./
token.module - A helper function that retrieves all currently exposed tokens, and merges them recursively. This is only necessary when building the token listing -- during actual value replacement, only tokens in a particular domain are requested and a normal…
File
- ./
token.api.php, line 25 - Hooks provided by the token module.
Code
function hook_token_list($type = 'all') {
$tokens = array();
if ($type == 'global' || $type == 'all') {
$tokens['global']['random-number'] = t('A randomly generated number.');
}
if ($type == 'node' || $type == 'all') {
$tokens['node']['node-random-nid'] = t("A randomly generated number between one and the node's unique ID.");
}
return $tokens;
}