function hook_token_info_alter

Same name in other branches
  1. 7.x modules/system/system.api.php \hook_token_info_alter()
  2. 8.9.x core/lib/Drupal/Core/Utility/token.api.php \hook_token_info_alter()
  3. 10 core/lib/Drupal/Core/Utility/token.api.php \hook_token_info_alter()
  4. 11.x core/lib/Drupal/Core/Utility/token.api.php \hook_token_info_alter()

Alter the metadata about available placeholder tokens and token types.

Parameters

$data: The associative array of token definitions from hook_token_info().

See also

hook_token_info()

Related topics

1 invocation of hook_token_info_alter()
Token::getInfo in core/lib/Drupal/Core/Utility/Token.php
Returns metadata describing supported tokens.

File

core/lib/Drupal/Core/Utility/token.api.php, line 255

Code

function hook_token_info_alter(&$data) {
    // Modify description of node tokens for our site.
    $data['tokens']['node']['nid'] = [
        'name' => t("Node ID"),
        'description' => t("The unique ID of the article."),
    ];
    $data['tokens']['node']['title'] = [
        'name' => t("Title"),
        'description' => t("The title of the article."),
    ];
    // Chained tokens for nodes.
    $data['tokens']['node']['created'] = [
        'name' => t("Date created"),
        'description' => t("The date the article was posted."),
        'type' => 'date',
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.