Forums Forums Search & Filter Pro change searchform.php template file to use S&F

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #191662

    Hey,
    I’ve set up an advanced search page, using search.php with a S&F shortcode. Now I’m trying to set S&F as my site default search system, but without all the advanced options (only 1 simple search field). I don’t want to do it using another shortcode, because I don’t want all the S&F files to be loaded on every page (I’ve deqeued them from all pages except is_search), so I guess it could work if I only change the search input’s name attribute in my searchform.php to use S&F parameters. Maybe changing name= from s to <?php echo get-s&f-search-slug ?>?_sf_s or something like that.
    Is it right? How can I accomplish that properly?

    Thanks,
    Itamar

    Anonymous
    #191665

    This is my searchform.php template file:

    
    <form method="get" id="searchform" action="/">
    	<input value="" name="s" id="s" type="text" placeholder="חיפוש..." role="search">
    	<label class="submit-wrapper">
    		<input id="ssbmt" type="submit" style="display: none;" />
    		<?php echo file_get_contents(get_stylesheet_directory_uri()."/images/search.svg"); ?>
    	</label>	
    </form>
    
    Trevor
    #191667

    Normally, you would edit the HTML of the template file (often the header.php or searchform.php file) and change the name="s" of the form to name="_sf_s"

    But I think this thread may have more detail and advice:

    https://support.searchandfilter.com/forums/topic/keep-the-search-request/

    Anonymous
    #191679

    Hey,
    First of all – thanks a lot, the link you provided was very helpful.
    Now I’d like to ask your support for another issue appeared as a result from your solution (or maybe it was before?):
    In my header.php file I have a function which relies on if(is_home()) function. It works as expected and return false for all pages except the home page, but apparently it returns true on the s&f search result page (aka search.php). why? and how can i fix it?

    Trevor
    #191685

    Unfortunately, this is something related to WordPress when you use our ‘As an Archive’ display results method.

    The only workaround is to look if on the search results page the body tag has the ‘search’ classnames attached (you can force this in our Advanced options).

    There is a function in WordPress where you can look at the classnames that are on the body tag, which are returned as an array, so you could then add that to the test.

    This thread might help:

    https://support.searchandfilter.com/forums/topic/search-result-is-always-interpreted-as-is_front_page-is_home/

    Anonymous
    #191701

    Thanks, your workaround did the trick:

    $classes = get_body_class();
    $is_search_page = false;
    if (in_array('search',$classes)) {
    	$is_search_page = true;
    }
    if(is_home() && $is_search_page == false) : 
    continiue... 
    

    I have some more questions, regarding other issues, so i’ll open a new topic for them.
    Thanks,
    Itamar

    Trevor
    #191705

    Thanks for sharing. I will close this thread for now.

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