Forums Forums Search & Filter Pro Reset Button Functionality

Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #267905

    Hi, how can I call the reset button functionality within a condition? Basically, I wanted to check if the category search term is present _sft_category then, I would like to reset the search query to be able to remove the _sft_scene_category on search term.

    Thanks!

    Trevor
    #267916

    I am sorry, I do not understand what you are trying to do? Are you able to explain in a lot more detail?

    Anonymous
    #267925

    Hi Trevor,

    Sorry, I think there was a typo on the category search term. I wanted to have an if statement that will check whether the search query has _sft_category. Then if that is true, I wanted to automatically reset the query to remove everything including the _sft_category.

    Currently, I have this code as a start but was stuck on how to call the reset function.

    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1184)->current_query();
    
    if ( $sf_current_query->get_field_string("_sft_category") ) :
      // reset the search query here
    endif;
    

    Thanks!

    Trevor
    #268012

    The problem, is that resetting the query will return the form to its original state, and the results to their default (all) state. So, in effect, what would happen is that, if a user selected a category, the form and results and reset to default.

    I was trying to understand WHY you wanted to do this?

    Did you want to remove the query string from the URL, or simply return the form to its default state, but leave the results still filtered?

    If either or both of these, I am sorry, but that is not possible.

    Anonymous
    #268039

    Hi Trevor,

    We are planning to have another taxonomy that we would like to include as search query, but if a user have that taxonomy as search query we would like to simply return the form to its default state. But of course we wanted the reset to trigger after a new search query is being added.

    Trevor
    #268074

    I am not entirely sure how you envisage that. I assume you have two fields in the form. Are you meaning that if the user selects a certain taxonomy term in one field, the other field then needs to set a certain value, and clear the choice the user makes?

    If that is what you want, I am not sure a reset is needed, or even the best solution. Instead, it might be best to have Auto Submit OFF, add a submit button to the form, and then create some JavaScript that monitors the field to see a certain choice has been made, and if it is, then reset that one field, and set the required value on the other field, then the user can submit the form as usual with the button, or indeed you could have the javascript trigger the submit button for you.

    That javascript would be custom and would have to be written by you. To trigger the submit, using JavaScript like (assuming the form has an ID of 1234) this:

    $('.searchandfilter[data-sf-form-id="1234"]').submit();

Viewing 6 posts - 1 through 6 (of 6 total)