Posted by andymilk on October 3, 2009 at 5:32pm
Is it possible to have an OR relationship with 2 or more Exposed Filters in a View?
I'd like to have ONE form field (a search term) form field. I'm going to use that value and populate the URL w/ the multiple filters.
For instance:
Search: FORM FIELD
Upon submitting the form, it'll go to this URL:
/books/?title=[FORM FIELD VALUE]&author=[FORM FIELD VALUE]
So I'm using the ONE form field value to search 2 exposed filters. The only problem is that it's an AND relationship, so it's not returning any results.
Is there a better way to use ONE form field to search multiple fields in a View?
Thanks,
Andy
Comments
_
I haven't tried it yet, but maybe the http://drupal.org/project/views_or module?
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
That did the trick, thanks
That did the trick, thanks for the suggestion!
Can you tell us how you did it?
@ andymilk
Can you post how you did this? I have the same situation, I have two exposed filters that I want to be searched using one form field. I've installed the Views Or module and tried several different filter combinations:
Views Or: Begin alternatives =
Content: Field 1 exposed
Content: Field 2 exposed
Views Or: End alternatives =
This would, in theory, use the "COALESCE" function, but any time I have both filters exposed I get all kinds of "invalid argument" errors on the view preview and when I search on Field 1 it doesn't give me the matching results from Field 2. Also, this means I still have two form fields on the view page since both filters are still exposed.
If I change it to this:
Views Or: Begin alternatives =
Content: Field 1 exposed
Content: Field 2 contains
Views Or: End alternatives =
Which means the second filter is not exposed, I get no preview errors and only one form on the view page, but a search only yields results from Field 1, not both.
I've also tried this:
Views Or: Begin alternatives =
Content: Field 1 exposed
Views Or: Next alternative =
Content: Field 2 exposed
Views Or: End alternatives =
Again, this gives me tons of "invalid arguments" errors and two exposed form fields and it still only shows results from field one, not both.
So, I change it to this:
Views Or: Begin alternatives =
Content: Field 1 exposed
Views Or: Next alternative =
Content: Field 2 contains
Views Or: End alternatives =
Which means Field 2 is no longer exposed. This gets rid of all errors and gets me back to only one form on the view page. But now the filtering doesn't work at all. I enter a search term in the one exposed form field and get all records returned, including those that do not contain the search term.
What am I missing???
_
FYI this type of functionality has just been committed to views 6-3-- merlin ftw!
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.