Filter/Search on multiple fields with Views 3.x
Submitted by Jeff Geerling on May 15, 2012 - 10:13am
A common need I run into with a ton of Drupal sites and Views is searching/filtering content based on multiple fields. For example, a lot of people would like to search for content using either the Title or the Body for a particular content type.
There are two primary solutions offered for this situation, but they both have downsides or are overly complex, in my opinion:
- Use the Computed Field module to create yet another field stored in the database, combining the two (or more) fields you want to search, then expose a filter for that field instead of both of the individual fields. (I don't like this because it duplicates content/storage, and involves an extra module to do so).
- Use the Views Filters Populate to invisibly populate a second field that you've added to a views OR group (using Views OR in Views 2.x, or the built-in AND/OR functionality in Views 3.x). (This module is slightly limited in that you can only work with strings, and again, it involves an extra module).
Instead of using an extra module, I simply do the following to achieve a multi-field search: