O'Reilly logo

Drupal 7 First Look by Mark Noble

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tokens

The Token API has also had several new methods added to it to make creation of tokens easier as well as making it possible to change tokens defined by other modules. Let's look at each new method in detail.

hook_tokens

hook_tokens($type, $tokens, array $data = array(), array $options = array())

This method is called to perform the actual translation of tokens from placeholders into the correct value for the text. The tokens array will contain a list of all tokens that were found in the source text. You should return an associative array with the values for each token that your module defines. For more information on translating tokens as well as the options available, see: http://api.drupal.org/api/function/hook_tokens/7.

hook_token_info ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required