All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Clearing the search:field_name value from URL using low_search:url tag

Bryan C 19 Nov 2015 16:04 question, complete

Hi,

I'm using Low Search on my site and I would like to be able to filter results by a custom field value using filter links on my search results page. I've been reading through the docs and I'm having a little trouble setting it up.

So far I've gotten to partially work using the {low_search:url} tag for the filter links, but I also have an "all" or "clear" link that I would like to use to clear the filters and that is where I'm having trouble.

My current code looks something like this:

{exp:low_search:results query="{segment_2}"} 
{if count == 1}
<ul class="filter">
<li><a href="{low_search:url result_page='search'}">All</a></li>
<li><a href="{low_search:url search:photo_or_vector='p' result_page='search'}">Photos</a></li>
<li><a href="{low_search:url search:photo_or_vector='v' result_page='search'}">Vectors</a></li>
</ul>
{/if}
{title}
{/exp:low_search:results}


The "Photo" and "Vector" links work perfectly and filter my initial keyword search. If I click the "All" link the last filter remains in the url.

I've tried a number of things like adding keywords='{low_search_keywords}' among other things, but nothing seems to work.

Any help would be greatly appreciated, and alternative filtering suggestions are welcome.

Thanks!

Replies

  1. Low 19 Nov 2015 16:12

    You should be able to use an empty param to remove it.

    {low_search:url search:photo_or_vector='' result_page='search'}


    To clear out all parameters, you can use reset="yes" on the URL tag.

  2. Bryan C 19 Nov 2015 16:19

    Awesome! Thank you! Not sure why I didn't try that.

  3. Bryan C 19 Nov 2015 16:25

    As a follow up, do you know of any possible way to show the total results count for each option. So say I search "backgrounds" and I get an {absolute_results} count of 70, but 57 of those are photos and 13 are vectors.

    I would want to display that info like: All (70) | Photos (57) | Vectors (13)

    Thank you.

  4. Low 19 Nov 2015 16:28

    That's no small question.

    I've been looking at how to do something like that for a while now, and still haven't found a definitive answer. There just isn't a way to do this efficiently at the moment, I'm afraid.

  5. Bryan C 19 Nov 2015 16:35

    Ok, that's what I figured. It seems like a feature that would be used quite a bit, but in my own searching I've been at a loss. Just wanted to see if you maybe had a solution. Thanks again.

  6. Low 19 Nov 2015 16:37

    It would indeed be a good feature, which is why I looked into it. As it stands now, EE's API doesn't allow it.