Drupal - Expose single filter of combination of two fields in views

I eventually got a solution from this. I followed the second primary solution offered although the blogger personally used hook_views_query_alter().

  1. installed the module Views filters populate.
  2. added two filters "First Name" and "Last Name" (both must not be exposed) and added them to a OR filter group (Views 3 supports this). I had to use the operator "Contains any word" for both fields, otherwise the query gave me no desired result.
  3. created a filter "Global: populate filters", added the two fields into this and exposed it.

This gave me a quick solution without hard coding.
Here is other helpful reference.


On my installation, D7 with Views 7.x-3.6, you can add a filter that is " Global: Combine fields filter" which will do exactly what you need, allow users to search on multiple fields with a single filter.


Its really easy.

  1. Click on Add a filter.
  2. select "Global: Combine fields filter"
  3. Follow the instructions.

Thanks.

Tags:

Views

7