function comment_token_info

Same name in other branches
  1. 9 core/modules/comment/comment.tokens.inc \comment_token_info()
  2. 8.9.x core/modules/comment/comment.tokens.inc \comment_token_info()
  3. 10 core/modules/comment/comment.tokens.inc \comment_token_info()
  4. 11.x core/modules/comment/comment.tokens.inc \comment_token_info()

Implements hook_token_info().

File

modules/comment/comment.tokens.inc, line 11

Code

function comment_token_info() {
    $type = array(
        'name' => t('Comments'),
        'description' => t('Tokens for comments posted on the site.'),
        'needs-data' => 'comment',
    );
    // Comment-related tokens for nodes
    $node['comment-count'] = array(
        'name' => t("Comment count"),
        'description' => t("The number of comments posted on a node."),
    );
    $node['comment-count-new'] = array(
        'name' => t("New comment count"),
        'description' => t("The number of comments posted on a node since the reader last viewed it."),
    );
    // Core comment tokens
    $comment['cid'] = array(
        'name' => t("Comment ID"),
        'description' => t("The unique ID of the comment."),
    );
    $comment['hostname'] = array(
        'name' => t("IP Address"),
        'description' => t("The IP address of the computer the comment was posted from."),
    );
    $comment['name'] = array(
        'name' => t("Name"),
        'description' => t("The name left by the comment author."),
    );
    $comment['mail'] = array(
        'name' => t("Email address"),
        'description' => t("The email address left by the comment author."),
    );
    $comment['homepage'] = array(
        'name' => t("Home page"),
        'description' => t("The home page URL left by the comment author."),
    );
    $comment['title'] = array(
        'name' => t("Title"),
        'description' => t("The title of the comment."),
    );
    $comment['body'] = array(
        'name' => t("Content"),
        'description' => t("The formatted content of the comment itself."),
    );
    $comment['url'] = array(
        'name' => t("URL"),
        'description' => t("The URL of the comment."),
    );
    $comment['edit-url'] = array(
        'name' => t("Edit URL"),
        'description' => t("The URL of the comment's edit page."),
    );
    // Chained tokens for comments
    $comment['created'] = array(
        'name' => t("Date created"),
        'description' => t("The date the comment was posted."),
        'type' => 'date',
    );
    $comment['changed'] = array(
        'name' => t("Date changed"),
        'description' => t("The date the comment was most recently updated."),
        'type' => 'date',
    );
    $comment['parent'] = array(
        'name' => t("Parent"),
        'description' => t("The comment's parent, if comment threading is active."),
        'type' => 'comment',
    );
    $comment['node'] = array(
        'name' => t("Node"),
        'description' => t("The node the comment was posted to."),
        'type' => 'node',
    );
    $comment['author'] = array(
        'name' => t("Author"),
        'description' => t("The author of the comment, if they were logged in."),
        'type' => 'user',
    );
    return array(
        'types' => array(
            'comment' => $type,
        ),
        'tokens' => array(
            'node' => $node,
            'comment' => $comment,
        ),
    );
}

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