I just want to create a simple "IN" filter for my taxonomy field with values that I calculate in the views_handler_filter subclass.

My subclass of views_handler_filter implements the function views_handler_filter->query(). I need to require that the tid of a taxonomy_term_reference field is in an array that I build there. How can I build the query to filter by field value?

views_plugin_query_default::add_where($group, $field, $value = NULL, $operator = NULL)

When calling $query->add_where(), the $field argument is simply described as "The name of the field to check." How can I join the filter query to the field data table and build my $field argument correctly for the taxonomy_term_reference field I need to filter by?


1 Answer 1


I solved my current problem in a similar way to the solution here: http://drupal.org/node/1259914

  1. Added a filter to the view with my taxonomy field as "not empty"

  2. Implemented hook_views_query_alter() to call $query->add_where with my field_table_name.field_data_column and the values I wanted to accept with the 'IN' operator.

That said, I'm still interested in the views_handler_filter->query() solution(s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.