function node_token_info

Same name in other branches
  1. 7.x modules/node/node.tokens.inc \node_token_info()
  2. 9 core/modules/node/node.tokens.inc \node_token_info()
  3. 8.9.x core/modules/node/node.tokens.inc \node_token_info()
  4. 11.x core/modules/node/node.tokens.inc \node_token_info()

Implements hook_token_info().

File

core/modules/node/node.tokens.inc, line 16

Code

function node_token_info() {
    $type = [
        'name' => t('Nodes'),
        'description' => t('Tokens related to individual content items, or "nodes".'),
        'needs-data' => 'node',
    ];
    // Core tokens for nodes.
    $node['nid'] = [
        'name' => t("Content ID"),
        'description' => t('The unique ID of the content item, or "node".'),
    ];
    $node['vid'] = [
        'name' => t("Revision ID"),
        'description' => t("The unique ID of the node's latest revision."),
    ];
    $node['type'] = [
        'name' => t("Content type"),
    ];
    $node['type-name'] = [
        'name' => t("Content type name"),
        'description' => t("The human-readable name of the node type."),
    ];
    $node['title'] = [
        'name' => t("Title"),
    ];
    $node['body'] = [
        'name' => t("Body"),
        'description' => t("The main body text of the node."),
    ];
    $node['summary'] = [
        'name' => t("Summary"),
        'description' => t("The summary of the node's main body text."),
    ];
    $node['langcode'] = [
        'name' => t('Language code'),
        'description' => t('The language code of the language the node is written in.'),
    ];
    $node['published_status'] = [
        'name' => t('Published'),
        'description' => t('The publication status of the node ("Published" or "Unpublished").'),
    ];
    $node['url'] = [
        'name' => t("URL"),
        'description' => t("The URL of the node."),
    ];
    $node['edit-url'] = [
        'name' => t("Edit URL"),
        'description' => t("The URL of the node's edit page."),
    ];
    // Chained tokens for nodes.
    $node['created'] = [
        'name' => t("Date created"),
        'type' => 'date',
    ];
    $node['changed'] = [
        'name' => t("Date changed"),
        'description' => t("The date the node was most recently updated."),
        'type' => 'date',
    ];
    $node['author'] = [
        'name' => t("Author"),
        'type' => 'user',
    ];
    return [
        'types' => [
            'node' => $type,
        ],
        'tokens' => [
            'node' => $node,
        ],
    ];
}

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