-
AuthorSearch Results
-
October 5, 2018 at 8:40 am #190171
In 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.
August 6, 2018 at 2:16 pm #184592In reply to: Remove all the result at the beginning
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).
July 5, 2018 at 3:08 pm #182014In reply to: Hide all results before a search query is made
TrevorParticipantYou would need to be using our Shortcode Display results method, and have followed the guide to customising:
Once you have a copy of the results.php file in a
search-filter
sub-folder of your theme, you can edit that file, like this (leave the PHP comments at the top outside and before this code):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 { // the results.php PHP code here }
Make sure you change the ID number in that snippet to the ID number of your form.
July 4, 2018 at 1:08 pm #181946In reply to: Hide all results before a search query is made
TrevorParticipantThe Custom method relies on a theme template of some sort. Are you using a theme php template, as the logic would look something like this to do as you want:
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 { // the theme template PHP code here }
Change the number 1024 with your form’s ID number (from the shortcode).
This code will likely need to be used within a part the template file that actually outputs the results (around the if query … have … posts bit).
-
AuthorSearch Results