Forums › Forums › Search & Filter Pro › change searchform.php template file to use S&F
Tagged: default search, search slug
- This topic has 6 replies, 2 voices, and was last updated 6 years ago by Trevor.
-
Anonymous(Private) October 24, 2018 at 10:29 am #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 exceptis_search
), so I guess it could work if I only change the search input’sname
attribute in mysearchform.php
to use S&F parameters. Maybe changingname=
froms
to<?php echo get-s&f-search-slug ?>?_sf_s
or something like that.
Is it right? How can I accomplish that properly?Thanks,
ItamarAnonymous(Private) October 24, 2018 at 10:32 am #191665This 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(Private) October 24, 2018 at 10:38 am #191667Normally, 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 toname="_sf_s"
But I think this thread may have more detail and advice:
https://support.searchandfilter.com/forums/topic/keep-the-search-request/
Anonymous(Private) October 24, 2018 at 11:15 am #191679Hey,
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 myheader.php
file I have a function which relies onif(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 (akasearch.php
). why? and how can i fix it?Trevor(Private) October 24, 2018 at 11:40 am #191685Unfortunately, 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:
Anonymous(Private) October 24, 2018 at 1:05 pm #191701Thanks, 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 -
AuthorPosts