Forums Forums Search & Filter Pro Manually setting and reading filters

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #18203

    Hi, I’ve been trying to do this myself but I wondered if there were any examples/suggestions you could provide.

    I’m trying 2 things:

    1) Use a fixed button/link to select a category. So for example if I have Categories A, B, C & D, I want to be able to add a button that will select Category A. Ideally this would update the url (?_sft_category=) and refresh the results in Ajax.

    2) Sort of reverse. Can you give me any examples etc to add code to the page to check what selections have been made. I am trying to add conditional text on the page depending on what category/taxonomy has been selected.

    I was looking in the forum and also at the reset link code but without luck so far. I realise that these are outside of normal use, was just wondering/hoping that you might have some example code etc.

    Thanks for your time,

    Cheers Bob

    Anonymous
    #18381
    This reply has been marked as private.
    Ross Moderator
    #18421

    Hi Bob

    Your ticket was on a list of the remaining few 😉

    So to answer your questions:

    1) You would need to change the values on the form itself, so you would do something along the lines of:

    • Create your button
    • When clicked call some JS function
    • This JS function should then update the search form, so you would do something like:
    $(".searchandfilter .sf-field-category select").val("category-name"); //sets a specific category in the dropdown
    $(".searchandfilter").submit(); //submit the form - S&F should handle this after and load via ajax etc if its enabled

    2) I recently answered a similar question which I think should help – https://support.searchandfilter.com/forums/topic/php-code-to-display-search-terms-on-search-results-page/#post-18377

    Thanks!

    Anonymous
    #18430

    Hi Ross,

    Thanks for the reply – know it can’t be easy.

    I’ll take a look at your suggestions and see how I get on. Just wanted to say I appreciate your response.

    Cheers

    Bob

    Ross Moderator
    #18483

    🙂

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