Forums › Forums › Search & Filter Pro › Alter Template After Filter Fires
Tagged: custom, if statement, results, template change
- This topic has 3 replies, 2 voices, and was last updated 4 years, 3 months ago by Trevor.
-
Anonymous(Private) August 6, 2020 at 4:37 am #255214
Hello,
I am looking to change my search form from using a custom search.php file to use the Custom results method and fire on the same page where the form exists. This works great for me in other instances but for this form, The sidebar where the results would show before using the form has specific content in it. I need to replace the content in that sidebar once someone hits one of the filters. Is there an if statement I can run in my template to change the code for the content that appears in this location once a filter is executed.
URL: https://domain.com/advanced-search/
After a filter is clicked: http://domain.com/advanced-search/?_sfm_types_of_partnerships=I have about 30+ filters but wasn’t sure if there is something I can use to swap out the default content and show the query template file id like once they use it.
Thanks!
Trevor(Private) August 6, 2020 at 11:41 am #255240The PHP to use to conditionally run code looks like this (change the ID of the form to suit):
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // the current (unfiltered) posts output code here } else { // the desired (filtered) posts output code here }
-
AuthorPosts