You are here

node_gallery_api_views_handler_comments_count.inc in Node Gallery 7

Creates an comments count handler that totals all comments made on a gallery and all images within it

File

includes/views/node_gallery_api_views_handler_comments_count.inc
View source
<?php

/**
 * @file
 * Creates an comments count handler that totals all comments made on a
 * gallery and all images within it
 */
class node_gallery_api_views_handler_comments_count extends views_handler_field_numeric {
  function query() {
    $this
      ->ensure_my_table();
    $sql = "SELECT COUNT(*) FROM {comments} c\n      LEFT JOIN {node_gallery_relationship} ngi on c.nid = ngi.nid\n      LEFT JOIN {node} n on c.nid = n.nid\n      WHERE (ngi.ngid = node.nid or n.nid = node.nid) AND n.status = 1";
    $this->field_alias = $this->query
      ->add_field(NULL, "({$sql})", 'comments_count');
  }

}

Classes

Namesort descending Description
node_gallery_api_views_handler_comments_count @file Creates an comments count handler that totals all comments made on a gallery and all images within it