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 5 years, 8 months ago by
Trevor.
-
Trevor(Private) March 17, 2020 at 9:28 am #236876
In 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
Ross Moderator(Private) March 19, 2020 at 11:25 am #237164Hi again
So I’ve had a chance to digest this ticket.
In regards to your two issues which are both part of the same problem:
The way a form submits / resets is to include the sliders at their min / max value. We will try to address this in v3 within the plugin, but for now, if you want to have the same set of results when you reset as when you land on the page you have 2 options:
a) set a default value on all other posts – you can write a query to loop through all posts where there is no value for this post meta, and then auto add a value like
0b) restict the meta query to the slider min/max params (you would have to use fixed min/max limits), you can do that from the
post metatab in your search form – this way the results that are shown when landing on the page, are teh same as when the form is reset / submitted, and the range slider params are added to the URL.—
In regards to the filter:
sf_edit_query_args, this is run before S&F applies its workings… S&F does a different kind of query, outside of your WP_Query, which is then combined with the WP_Query, so you can never truly unset that value. Your best bet would be to simply dounset($_GET['filter_name']);(you can dump this in the bottom of your functions.php to test) before S&F grabs the value and applies its sorting.I hope that clears a few things up for you?
Let me know if you have any further questions.
Thanks
-
AuthorPosts