function taxonomy_field_views_data_alter

Same name in other branches
  1. 8.9.x core/modules/taxonomy/taxonomy.views.inc \taxonomy_field_views_data_alter()
  2. 10 core/modules/taxonomy/taxonomy.views.inc \taxonomy_field_views_data_alter()
  3. 11.x core/modules/taxonomy/taxonomy.views.inc \taxonomy_field_views_data_alter()

Implements hook_field_views_data_alter().

Views integration for entity reference fields which reference taxonomy terms. Adds a term relationship to the default field data.

See also

views_field_default_views_data()

File

core/modules/taxonomy/taxonomy.views.inc, line 62

Code

function taxonomy_field_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
    if ($field_storage->getType() == 'entity_reference' && $field_storage->getSetting('target_type') == 'taxonomy_term') {
        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']['id'] = 'taxonomy_index_tid';
                }
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.