You are here

function views_calc_views_data in Views Calc 7

Same name and namespace in other branches
  1. 6.3 views_calc.views.inc \views_calc_views_data()
  2. 6 views_calc.views.inc \views_calc_views_data()

Implements hook_views_data().

Add calc fields to views field list.

File

./views_calc.views.inc, line 7

Code

function views_calc_views_data() {
  $data = array();
  $results = _views_calc_fields();
  foreach ($results as $field) {
    $data[$field->base]['cid' . $field->cid] = array(
      'group' => t('Views Calc'),
      'title' => t($field->label),
      'help' => $field->calc,
      'field' => array(
        'field' => 'cid' . $field->cid,
        'table' => $field->base,
        'handler' => 'views_calc_field_handler',
        'click sortable' => TRUE,
        'allow empty' => TRUE,
        'cid' => $field->cid,
        'format' => $field->format,
        'custom' => $field->custom,
        'calc' => $field->calc,
      ),
      'sort' => array(
        'handler' => 'views_calc_handler_sort',
      ),
    );
  }
  return $data;
}