You are here

function content_views_field_query_handler in Content Construction Kit (CCK) 5

1 string reference to 'content_views_field_query_handler'
content_views_field_tables in ./content_views.inc

File

./content_views.inc, line 122
Interface between content.module and views.module.

Code

function content_views_field_query_handler($field, &$fieldinfo, &$query) {
  if (in_array($field['handler'], array(
    'content_views_field_handler_group',
    'content_views_field_handler_first',
    'content_views_field_handler_last',
  ))) {

    // we manage the addition of fields ourselves
    // if not multiple field, add the columns to the query
    if (!$fieldinfo['content_field']['multiple']) {
      $query
        ->add_field($field['field'], $field['tablename'], $field['queryname']);
      foreach ($fieldinfo['addlfields'] as $name) {
        $query
          ->add_field($name, $field['tablename'], "{$field['tablename']}_{$name}");
      }
    }
    else {

      // if the field is sortable (table sort), then we have to join the table
      // ("Node: Distinct" will be required to avoid duplicates...)
      if ($field['sortable']) {
        $query
          ->ensure_table($field['tablename']);
      }
    }

    // make sure views default query builder does not add anything
    $fieldinfo['notafield'] = true;
    unset($fieldinfo['addlfields']);
  }
}