1 node.tokens.inc | node_token_info() |
Implements hook_token_info().
File
- core/
modules/ node/ node.tokens.inc, line 10 - Builds placeholder replacement tokens for node-related data.
Code
function node_token_info() {
$types = array(
'node' => array(
'name' => t('Content'),
'description' => t('Tokens related to individual pieces of content, or "nodes".'),
'needs-data' => 'node',
),
'content-type' => array(
'name' => t('Content types'),
'description' => t('Tokens related to content types.'),
'needs-data' => 'node_type',
),
);
// Node tokens.
$node['nid'] = array(
'name' => t('Content ID'),
'description' => t('The unique ID of the content item, or "node".'),
);
$node['content-type'] = array(
'name' => t('Content type'),
'description' => t('The human-readable name of the content type.'),
'type' => 'content-type',
);
// @deprecated: Use node:content-type:name
$node['type-name'] = array(
'name' => t('Content type name'),
'description' => t('The human-readable name of the content type.'),
'deprecated' => TRUE,
);
// @deprecated: Use node:content-type
$node['type'] = array(
'name' => t('Content type'),
'description' => t('The machine name of the content type.'),
'deprecated' => TRUE,
);
$node['title'] = array(
'name' => t('Title'),
'description' => t('The title of the node.'),
);
$node['body'] = array(
'name' => t('Body'),
'description' => t('The main body text of the node.'),
);
$node['summary'] = array(
'name' => t('Summary'),
'description' => t("The summary of the node's main body text."),
);
$node['langcode'] = array(
'name' => t('Language code'),
'description' => t('The language code of the language the node is written in.'),
);
$node['url'] = array(
'name' => t('URL'),
'description' => t('The URL of the node.'),
'type' => 'url',
);
$node['edit-url'] = array(
'name' => t('Edit URL'),
'description' => t("The URL of the node's edit page."),
'type' => 'url',
);
$node['tnid'] = array(
'name' => t('Translation set ID'),
'description' => t('The unique ID of the original-language version of this node, if one exists.'),
);
$node['source'] = array(
'name' => t('Translation source node'),
'description' => t("The source node for this current node's translation set."),
'type' => 'node',
);
$node['vid'] = array(
'name' => t('Revision ID'),
'description' => t("The unique ID of the node's latest revision."),
);
$node['log'] = array(
'name' => t('Revision log message'),
'description' => t('The explanation of the most recent changes made to the node.'),
);
// Chained tokens for nodes.
$node['created'] = array(
'name' => t('Date created'),
'description' => t('The date the node was posted.'),
'type' => 'date',
);
$node['changed'] = array(
'name' => t('Date changed'),
'description' => t('The date the node was most recently updated.'),
'type' => 'date',
);
$node['author'] = array(
'name' => t('Author'),
'description' => t('The author of the node.'),
'type' => 'user',
);
// Content type tokens.
$content_type['name'] = array(
'name' => t('Name'),
'description' => t('The human-readable name of the content type.'),
);
$content_type['machine-name'] = array(
'name' => t('Machine-readable name'),
'description' => t('The unique machine-readable name of the content type.'),
);
$content_type['description'] = array(
'name' => t('Description'),
'description' => t('The optional description of the content type.'),
);
$content_type['node-count'] = array(
'name' => t('Node count'),
'description' => t('The number of nodes belonging to the content type.'),
);
// Check to see if translation modules are enabled before showing tokens.
if (!module_exists('translation')) {
$node['tnid']['restricted'] = TRUE;
$node['source']['restricted'] = TRUE;
}
return array(
'types' => $types,
'tokens' => array(
'node' => $node,
'content-type' => $content_type,
),
);
}