Example: Token API

  1. drupal
    1. 8
    2. 6
    3. 7

Examples using the Token API.

The Token module provides an API for providing tokens to other modules. Tokens are small bits of text that can be placed into larger documents via simple placeholders, like %site-name or [user].

This example is part of the Examples for Developers Project which you can download and experiment with here: http://drupal.org/project/examples

Functions & methods

token_example_entity_info_alterImplements hook_entity_info_alter().
token_example_example_formForm builder; display lists of supported token entities and text to tokenize.
token_example_example_form_submitSubmit callback; store the submitted values into storage.
token_example_menuImplements hook_menu().
token_example_tokensImplements hook_tokens().
token_example_token_infoImplements hook_token_info().
_token_example_get_commentBuilds a list of available comments.
_token_example_get_fileBuilds a list of available files.
_token_example_get_nodeBuilds a list of available content.
_token_example_get_taxonomy_termBuilds a list of available taxonomy terms.
_token_example_get_userBuilds a list of available user accounts.

examples/token_example/token_example.module, line 12