Support Forums

Looking for support? You can access the support system via your account.

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

Tagged: ,

Viewing 10 posts - 1 through 10 (of 13 total)
  • White
    #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:

    1. 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?
    2. 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 Moderator
    #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.

    White
    #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 Moderator
    #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.

    White
    #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.

    White
    #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 Moderator
    #236978

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

    White
    #236980

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

    Trevor Moderator
    #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

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

The topic ‘Range Slider is getting triggered by default’ is closed to new replies.