You are here

function token_token_list in Token 5

Same name and namespace in other branches
  1. 6 token.module \token_token_list()

Sample implementation of hook_token_list(). Documents the individual tokens handled by your module.

Parameters

type: A flag indicating the class of substitution tokens to return information on. If this is set to 'all', a complete list is being built and your module should return its full list, regardless of type. Global tokens should always be returned, regardless of the $type passed in.

Return value

A keyed array listing the substitution tokens. Elements should be in the form of: $list[$type][$token] = $description

File

./token.module, line 138
The Token API module.

Code

function token_token_list($type = 'all') {
  $tokens = array();
  if ($type == 'global' || $type == 'all') {

    // Current user tokens.
    $tokens['global']['user-name'] = t('The name of the currently logged in user.');
    $tokens['global']['user-id'] = t('The user ID of the currently logged in user.');
    $tokens['global']['user-mail'] = t('The email address of the currently logged in user.');

    // Site information tokens.
    $tokens['global']['site-url'] = t("The URL of the site's front page.");
    $tokens['global']['site-name'] = t('The name of the site.');
    $tokens['global']['site-slogan'] = t('The slogan of the site.');
    $tokens['global']['site-mission'] = t("The optional 'mission' of the site.");
    $tokens['global']['site-mail'] = t('The administrative email address for the site.');
    $tokens['global'] += token_get_date_token_info(t('The current'), 'site-date-');

    // Current page tokens.
    $tokens['global']['current-page-title'] = t('The title of the current page.');
    $tokens['global']['current-page-path'] = t('The URL alias of the current page.');
    $tokens['global']['current-page-path-raw'] = t('The URL alias of the current page.');
    $tokens['global']['current-page-url'] = t('The URL of the current page.');
    $tokens['global']['current-page-number'] = t('The page number of the current page when viewing paged lists.');
  }
  return $tokens;
}