function views_handler_field_content_multiple::pre_render in Content Construction Kit (CCK) 6
File
- includes/
content.views.inc, line 417
Class
- views_handler_field_content_multiple
- An extended subclass for field handling that adds multiple field grouping.
Code
function pre_render($values) {
// There are no values to render in a summary view.
if (isset($this->view->build_info['summary'])) {
return parent::pre_render($values);
}
// If this is not a grouped field, use the parent pre_render().
if (!$this->defer_query || empty($values)) {
return parent::pre_render($values);
}
$field = $this->content_field;
$db_info = content_database_info($field);
$options = $this->options;
$this->field_values = array();
// Build the list of nids to retrieve.
// TODO : try fetching from cache_content first ??
$nids = array();
foreach ($values as $value) {
$nids[] = $value->nid;
}
// List columns to retrieve.
$table_alias = content_views_tablename($field);
$query_columns = array(
"{$table_alias}.delta AS delta",
);
foreach ($db_info['columns'] as $column => $attributes) {
$query_columns[] = "{$table_alias}.{$attributes['column']} AS {$column}";
}
// Note : this query doesn't need to run through db_rewrite_sql, since the
// nids we retrieve have been selected by the views query, which already takes
// care of this.
$query = "SELECT node.nid, " . implode(', ', $query_columns) . " FROM {node} node" . " LEFT JOIN {" . $db_info['table'] . "} {$table_alias} ON node.vid = {$table_alias}.vid" . " WHERE node.nid IN (" . implode(',', $nids) . ")" . " ORDER BY node.nid ASC, {$table_alias}.delta " . ($options['multiple']['multiple_reversed'] ? 'DESC' : 'ASC');
// TODO : Select all deltas or only a subset.
$result = $options['multiple']['multiple_number'] ? db_query_range($query, $options['multiple']['multiple_from'], $options['multiple']['multiple_number']) : db_query($query);
while ($item = db_fetch_array($result)) {
$this->field_values[$item['nid']][$item['delta']] = $item;
}
}