Alter Template After Filter Fires

Forums › Forums › Search & Filter Pro › Alter Template After Filter Fires

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #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
    #255240

    The 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
    }
    Anonymous
    #255314

    Perfect, thank you!

    Trevor
    #255316

    Thanks for getting back to me. I will close this thread for now.

Viewing 4 posts – 1 through 4 (of 4 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.