Taxonomy term reference fields should provide a relationship to taxonomy terms, to take advantage of the more mature filters, arguments, etc. available to taxonomy terms.
In Drupal 7, entities relate to taxonomy terms primarily via fields. Drupal 7's {taxonomy_index} table ONLY joins between terms and current node revisions, which means that it's only useful when you want to filter nodes by terms but not restricted by vocabulary.
This relationship makes taxonomy terms useful on non-node entities; without this relationship there is no way to filter non-node entities (like users) by taxonomy.
The attached patch implements hook_field_views_data_alter() and adds a relationship to each taxonomy term reference field.
Comments
Comment #1
becw commentedUpdated patch with a better relationship label.
Comment #2
dawehnerWouldn't it be better to use hook_field_views_data, see modules/field.views.inc list_field_views_data?
It's a bit easier code and it's much easier to be altered by a custom module because the custom module alter always happens later.
Comment #3
becw commentedYeah, that's probably a good idea, though I would still call the
field_field_views_data()that Views provides, since I have no desire to duplicate that code.Comment #4
dawehnerOh sure, that's recommended. Like list_field_views_data does it :)
Comment #5
becw commentedHere's an updated patch that implements
hook_field_views_data()for taxonomy.Comment #6
das-peter commentedThanks bec - that's exactly what I was looking for. Works like a charm :)
Comment #7
dawehnerThanks again!