1.20.x taxonomy.views.inc taxonomy_field_views_data($field)

Implements hook_field_views_data().

Views integration for taxonomy_term_reference fields. Adds a term relationship to the default field data.

See also

field_views_field_default_views_data()

File

modules/taxonomy/views/taxonomy.views.inc, line 347
Provide views data and handlers for taxonomy.module.

Code

function taxonomy_field_views_data($field) {
  $data = field_views_field_default_views_data($field);
  foreach ($data as $table_name => $table_data) {
    foreach ($table_data as $field_name => $field_data) {
      if (isset($field_data['filter']) && $field_name != 'delta') {
        $data[$table_name][$field_name]['filter']['handler'] = 'views_handler_filter_term_node_tid';
        $data[$table_name][$field_name]['filter']['vocabulary'] = $field['settings']['allowed_values'][0]['vocabulary'];
      }
    }

    // Add the relationship only on the tid field.
    $data[$table_name][$field['field_name'] . '_tid']['relationship'] = array(
      'handler' => 'views_handler_relationship',
      'base' => 'taxonomy_term_data',
      'base field' => 'tid',
      'label' => t('term from !field_name', array('!field_name' => $field['field_name'])),
    );

  }

  return $data;
}