You are here

function token_custom_token_info in Custom Tokens 7

Same name and namespace in other branches
  1. 8 token_custom.module \token_custom_token_info()
  2. 7.2 token_custom.module \token_custom_token_info()

Implements hook_token_info().

File

./token_custom.module, line 101
It gives the user the ability to create custom tokens using PHP code for specific replacements that can improve other modules relying on the token Drupal 7 core API.

Code

function token_custom_token_info() {
  $tokens = array();
  $data = token_custom_load_multiple();
  foreach ($data as $token) {

    //Add our 'custom' token type if necessary
    if ($token->type == 'custom' && !isset($tokens['types']['custom'])) {
      $tokens['types']['custom'] = array(
        'name' => t('Custom tokens'),
        'description' => t('Customized tokens for the custom token module'),
      );
    }
    $tokens['tokens'][$token->type][$token->machine_name] = array(
      'name' => $token->name,
      'description' => $token->description,
    );
  }
  return $tokens;
}