function comment_views_data_alter

Same name in other branches
  1. 6.x-3.x modules/comment.views.inc \comment_views_data_alter()

Implements hook_views_data_alter() on behalf of comment.module.

Add items to the node table that are relevant to comments.

File

modules/comment.views.inc, line 587

Code

function comment_views_data_alter(&$data) {
    // New comments.
    $data['node']['new_comments'] = array(
        'title' => t('New comments'),
        'help' => t('The number of new comments on the node.'),
        'field' => array(
            'handler' => 'views_handler_field_node_new_comments',
            'no group by' => TRUE,
        ),
    );
    $data['node']['comments_link'] = array(
        'field' => array(
            'title' => t('Add comment link'),
            'help' => t('Display the standard add comment link used on regular nodes, which will only display if the viewing user has access to add a comment.'),
            'handler' => 'views_handler_field_comment_node_link',
        ),
    );
    // Comment status of the node.
    $data['node']['comment'] = array(
        'title' => t('Comment status'),
        'help' => t('Whether comments are enabled or disabled on the node.'),
        'field' => array(
            'handler' => 'views_handler_field_node_comment',
            'click sortable' => TRUE,
        ),
        'sort' => array(
            'handler' => 'views_handler_sort',
        ),
        'filter' => array(
            'handler' => 'views_handler_filter_node_comment',
        ),
    );
    $data['node']['uid_touch'] = array(
        'title' => t('User posted or commented'),
        'help' => t('Display nodes only if a user posted the node or commented on the node.'),
        'argument' => array(
            'field' => 'uid',
            'name table' => 'users',
            'name field' => 'name',
            'handler' => 'views_handler_argument_comment_user_uid',
            'no group by' => TRUE,
        ),
        'filter' => array(
            'field' => 'uid',
            'name table' => 'users',
            'name field' => 'name',
            'handler' => 'views_handler_filter_comment_user_uid',
        ),
    );
    $data['node']['cid'] = array(
        'title' => t('Comments of the node'),
        'help' => t('Relate all comments on the node. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.'),
        'relationship' => array(
            'group' => t('Comment'),
            'label' => t('Comments'),
            'base' => 'comment',
            'base field' => 'nid',
            'relationship field' => 'nid',
            'handler' => 'views_handler_relationship',
        ),
    );
}