Forums Forums Search & Filter Pro Range Slider is getting triggered by default

Tagged: ,

Viewing 10 posts - 1 through 10 (of 12 total)
  • Trevor
    #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
    #236881

    Thanks 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
    #236885

    I 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
    #236889

    Thanks for this. I am already using manual min and max value. I will try with the filter, and wait for the reply from the developer, Ross.

    Anonymous
    #236976

    I 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!

    Trevor
    #236978

    The argument name may be case sensitive? I feel it should be lower case.

    Anonymous
    #236980

    _sfm_LENGTH_KEY is just a dummy key. I am using actual case sensitive key in my code.

    Trevor
    #236982

    I will need for Ross to pick this up then.

    Ross Moderator
    #237024

    Hi there

    Just to let you know I’m looking at this today – I’ll update with any questions.

    Thanks

    Ross Moderator
    #237164

    Hi 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 0

    b) 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 meta tab 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 do unset($_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

Viewing 10 posts - 1 through 10 (of 12 total)