You are here

function hook_token_list in Token 5

Same name and namespace in other branches
  1. 6 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.

7 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
comment_token_list in ./token_comment.inc
Implementation of hook_token_list().
content_token_list in ./token_cck.inc
node_token_list in ./token_node.inc
Implementation of hook_token_list().
taxonomy_token_list in ./token_taxonomy.inc
Implementation of hook_token_list().

... See full 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() {
  $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;
}