Forums › Forums › Search & Filter Pro › Manually setting and reading filters
- This topic has 4 replies, 2 voices, and was last updated 9 years, 5 months ago by Ross.
-
Anonymous(Private) May 25, 2015 at 4:35 pm #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
Ross Moderator(Private) May 28, 2015 at 4:46 pm #18421Hi 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!
-
AuthorPosts