You are here

data_node_views_handler_field_item_count.inc in Data 6

Class defition for data_node_views_handler_field_item_count.

File

data_node/views/data_node_views_handler_field_item_count.inc
View source
<?php

/**
 * @file
 * Class defition for data_node_views_handler_field_item_count.
 */
class data_node_views_handler_field_item_count extends views_handler_field {
  function query() {
    return;
  }
  function pre_render($result) {
    $this->items = array();
    foreach ($result as $row) {
      if (!empty($row->{$this->view->base_field})) {
        $nid = $row->{$this->view->base_field};
        $this->items[$nid] = db_result(db_query("SELECT COUNT(id) AS count FROM {data_table_node} WHERE nid = %d", $nid));
      }
    }
  }
  function render($values) {
    if (!empty($values->{$this->view->base_field})) {
      $nid = $values->{$this->view->base_field};
      if (isset($this->items[$nid])) {
        return check_plain($this->items[$nid]);
      }
    }
    return 0;
  }

}

Classes

Namesort descending Description
data_node_views_handler_field_item_count @file Class defition for data_node_views_handler_field_item_count.