-
AuthorSearch Results
-
October 16, 2018 at 11:58 am #191063
In reply to: Echo the query/search term
TrevorParticipantShowing the word searched for is not so difficult. If you have other filters, then it becomes a little more complex, but I can give you links. The documentation page:
https://searchandfilter.com/documentation/accessing-search-data/
This thread might help you:
https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/
… and this search will give similar threads I think:
https://support.searchandfilter.com/forums/search/sf_current_query+get_array+field+%5Bvalue%5D/
October 10, 2018 at 4:00 pm #190680In reply to: Current filters and reset buttons
TrevorParticipantShowing them is one thing, and quite complex, but I can give you links. Adding x’s to remove them is far more difficult. You would, in either case, have to do the coding yourself, as such custom coding is outside of our normal support. I think this feature is coming in V3, which is in development.
This thread might help you:
https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/
… and this search will give similar threads I think:
https://support.searchandfilter.com/forums/search/sf_current_query+get_array+field+%5Bvalue%5D/
October 9, 2018 at 7:35 am #190495In reply to: Limit search results before filtering
AnonymousInactivePerfect, that works. Thank you very much!
For others, the answer was to add the following lines in the results.php, which adds a “not-sf-filtered” or “sf-filtered” class:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1075)->current_query(); if (!$sf_current_query->is_filtered()) { $is_filtered = " not-sf-filtered"; } else { $is_filtered = " sf-filtered"; } ?> <div class="content-width<?php echo $is_filtered;?>">
October 5, 2018 at 8:40 am #190171In reply to: Hide Results until Search is Submitted
TrevorParticipantIf you are using the Shortcode results method, and our results.php template file, it would look like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code/loop OR results.php code here }
Change 1024 to the ID number of your form (from the form shortcode).
September 19, 2018 at 10:51 am #188787In reply to: Problems as soon as ajax is activated
TrevorParticipantOtherwise you would have to dig in and edit the template code to add a classname somewhere appropriate. You CAN use PHP to detect if a search has been made, like this (change the ID number to match your form – the get_search_term part is only needed if you have a text search field):
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // code if no search made } else { // code if search made }
September 7, 2018 at 5:49 pm #187728
TrevorParticipantI would need that user to log in and post the question, sorry. However, you want a no search set of results, and then a search set of results? If so, this should help you:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // your NO results code here } else { // your results code here }
August 29, 2018 at 2:31 pm #186695In reply to: Accessing the Search Data
TrevorParticipantThis thread might help you:
https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/
… and this search will give similar threads I think:
https://support.searchandfilter.com/forums/search/sf_current_query+get_array+field+%5Bvalue%5D/
August 17, 2018 at 3:04 pm #185868In reply to: Prevent empty search fetching results
TrevorParticipantIf you are using the Shortcode results method, and our results.php template file, it would look like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code/loop OR results.php code here }
Change 1024 to the ID number of your form (from the form shortcode).
August 17, 2018 at 11:01 am #185844In reply to: Search & Filter and Beaver Builder Search Template
TrevorParticipantHi Rose. I think this code will do as you want, but note that you need to change the ID of the form used. Also note that the Post Snippet plugin does not require the use of
<?php
and?>
.global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ($sf_current_query->get_search_term()=="") { echo '<h2>No Search Term</h2>'; } else { echo '<h2>Results for: ' . $sf_current_query->get_search_term() . '</h2>'; }
i hope that works. Modify the HTML and messages to suit.
August 14, 2018 at 11:19 am #185435In reply to: Showing search results
TrevorParticipantThe text that starts:
Architecten, interieurdesigners, vormgevers …
What about the title? and the breadcrumbs?
And you want to stay on that page? This means the display of the text needs to be conditional, and that means that you would need to output the text conditionally using PHP (the PHP needs to detect if a search has been made). The safest way to do this is to create the PHP as a shortcode and place the shortcode in to a Visual Composer (Page Builder) Text element.
This plugin allows you to create a shortcode with PHP in it:
https://wordpress.org/plugins/php-code-widget/
The PHP would look something like:
global $searchandfilter; $sf_current_query = $searchandfilter->get(187)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your page title, breadcrumbs, text here }
That is the theory of it.
-
AuthorSearch Results