Forums › Forums › Search & Filter Pro › Range Slider is getting triggered by default
Tagged: range slider, V3
- This topic has 12 replies, 3 voices, and was last updated 4 years, 9 months ago by Trevor.
-
Anonymous(Private) March 17, 2020 at 5:58 am #236872
Hello,
I am using “Search & Filter Pro” with ACF. I have one range slider (named “length”) with min value 25 to max 100. Same field for start and end key. Form is auto submitting with “AND” relation. Search form and result are the same page, and using custom method. I am having two issues:
- First, when I first load search page (without any URL parameter), it shows all posts by default, including all length values (0 to everything, even if post doesn’t have any length value), which is perfect. But when I click on one of the filter item (for example: a checkbox item), range slider gets automatically triggered and results are showing with the “checkbox” and “length” from 25-100. It should have only show filtered result for the “checkbox”. If I set range slider from 0 to 100. It still gets triggered automatically. But in this case, it shows posts without “length” filtered (shows all posts even if out of 100 or doesn’t have any length value). So, how do I turn of this automatic triggering?
- Second issue is with “reset filter”. When I click reset, it should have cleared all filters. But it keeps range slider still on, with values reset from min to max – and keeps URL parameter. So, instead of showing all posts, it only shows posts with length 25 to 100, as it never gets reset/cleared. How to solve this please?
You can check both of these issues on your live demo as well: https://demo.searchandfilter.com/movies/
I I click on “Action” from “Genres” (or any value except slider), it automatically includes “Rating” slider, and searches for “?_sft_sfdc_genre=action&_sfm_sfdc_vote_average=0+10”.
Then again, when I click “reset”, it still keeps “?_sfm_sfdc_vote_average=0+10” on URL.Kindly provide some solution to overcome these two issues.
Thanks.
Trevor(Private) March 17, 2020 at 9:28 am #236876In both cases the behavior you see is intended, and, at the moment, cannot be changed. Read more about this here:
https://support.searchandfilter.com/forums/topic/custom-max-price-for-price-slider/#post-77119
The only alternative is to not use range sliders.
Instead, you might be better to have secondary related search fields where choices are offered that encompass the precise values entered (where applicable):
So, a Secondary ‘Length’ field might look like the following options (in checkbox type filter):
Not available
0-10m
10m-20m
20m +That way you avoid this problem entirely.
We do, in V3 (due in a few months) intend to offer variations on range behaviors.
Anonymous(Private) March 17, 2020 at 9:53 am #236881Thanks for your response. Unfortunately, this is not going to be very helpful for me. I will need to use the slider with avoiding those two problems. Reset option can be solved with a direct link to the page -will be a page reload, but still solves the problem.
But, I will need to find some workaround to avoid the first issue. It’s not a good idea, but I will have to edit core plugin files to avoid this.
Can I have a head start please, if possible? Which file should I be looking for this?By the way, I think at least, the reset button/link one should have been a fresh entry. A reset means a full filter clear – removing everything, including slider.
Thanks.
Trevor(Private) March 17, 2020 at 9:59 am #236885I need to refer this to the plugin developer, Ross, to see if there is a way to use this filter:
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
(or another he might know of)
To examine the values for a range field and compare those to the default value, and if they are at the default value, remove that part of the query. It might require that Auto Detect min and max are not set (that min and max are set manually) so that they can be known in the code.
Anonymous(Private) March 17, 2020 at 3:16 pm #236976I tried to unset the slider using
sf_edit_query_args
, but it doesn’t clear the search results. It still keeps the slider query!This is what I have tried:
function filter_function_name( $query_args, $sfid ) { global $searchandfilter; $current_query = $searchandfilter->get(58376)->current_query()->get_array(); unset( $current_query['_sfm_LENGTH_KEY'] ); return $query_args; } add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );
But it doesn’t do anything! Posts are still being filtered with the slider query!
Ross Moderator(Private) March 18, 2020 at 8:46 am #237024Hi there
Just to let you know I’m looking at this today – I’ll update with any questions.
Thanks
-
AuthorPosts