Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using Views Facets, and I have a current search block resetting filters in my facet blocks. I have a search block that is a Views exposed filter on my index (for title). How can I get my reset filters link to also clear this Views exposed block?
Or, is there a text search functionality that I can use instead of a Views exposed filter?
Comment | File | Size | Author |
---|---|---|---|
#2 | facetapi_bonus-reset_all_querystrings-2203479-2.patch | 3.13 KB | azinck |
#1 | facetapi_bonus-reset_all_querystrings-2203479-1.patch | 3.09 KB | azinck |
Comments
Comment #1
azinck CreditAttribution: azinck commentedThis is tricky since I can't see a way to reset the views exposed filters in an intelligent fashion without wiping out all querystrings. For my use-cases, however, this is ok, so this patch adds an option to do a "complete reset" which will wipe out all querystrings.
Comment #2
azinck CreditAttribution: azinck commentedSmall tweak.
Comment #3
ptmkenny CreditAttribution: ptmkenny commentedAnother "quick and dirty" way to do this if you're using Facet API Pretty Paths is simply to add a text link back to the root path of the view and call it "reset filters." Going back to the root path will wipe out all the Views exposed filters.
Comment #4
PQ CreditAttribution: PQ commentedIf you know exactly what fields you want to unset and don't want to clobber everything on the query string, and are willing and able to put some code in a custom module then you can do the following:
$variables = array(...
:...where 'search' is the key that appears in the query string when you use the exposed filter. Add multiple lines if you have multiple exposed filters.
The whole file should look something like this:
files[] = current_search_reset_filters_and_search_link.inc
(Make sure the filename is the same as the one you made earlier.
Change "MY_MODULE" to your module name.
This should then work exactly the same as before but also strip out the query from the exposed filter(s) when clicked.