-
AuthorSearch Results
-
October 9, 2019 at 10:03 am #223272
In reply to: Hide results until submit bottom is clicked
TrevorParticipantSuch functionality would be within the scope of the theme and the template in use. Other than when the shortcode method is being used, our plugin has no direct control over your required behavior.
The coding required would look something like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(85204)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your current results template code here }Where the ID number (85204) would need to be whatever ID number your form is.
October 7, 2019 at 3:15 pm #223002In reply to: Accessing the Search Data
TrevorParticipantTo fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. 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
Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
You could temporarily use this code in your results template to display the full filter array so that you can work out the exact array part that holds the data you want:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(1391)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query,true),'</pre>'; ?>Where the ID needs to match that of your form.
October 7, 2019 at 12:32 pm #222988Topic: Accessing the Search Data
in forum Search & Filter Pro
AnonymousInactiveI want to do some custom formatting depending on the used filters… I tried this:
global $searchandfilter;
$sf_current_query = $searchandfilter->get(69991)->current_query();
echo $sf_current_query->get_fields_html(
array(“_sfm_mk_quelle_affiliate_shop”),
$args
);… and: echo $sf_current_query->get_field_string(“_sfm_mk_quelle_affiliate_shop”);
And took the field name from my search url:
https://miriamkreativ.de/material?_sfm_mk_quelle_affiliate_shop=Creativ-DiscountBut there is nothing shown unfortunately…
I tried one more thing (displaying the searchg term):
global $searchandfilter;
$sf_current_query = $searchandfilter->get(69991)->current_query();
echo $sf_current_query->get_search_term();… and this works for me. So please can you help me with the first example, showing / getting the chosen “affiliate shop”-option?
October 4, 2019 at 12:53 pm #222869In reply to: You searched for (including filters)?
TrevorParticipantTo fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. 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
Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
You could use this to display the filter array:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(1391)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query,true),'</pre>'; ?>Where the ID needs to match that of your form.
September 30, 2019 at 11:41 am #222314
TrevorParticipantThat will be a function from your theme to see if a standard WordPress text search has been made, which indeed would be required to remove. Make sure you are using a child theme and name this file differently, and point our search to use this new file as the template.
Our plugin, if you want to make a similar check if a search has been made, would use code like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(85204)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your current results template code here }Where the IF condition is set to display a different message if no search has been made (you can obviously change what it says, including adding HTML etc). Laos, change the ID number 85204 to whatever ID number our form is.
September 4, 2019 at 12:21 pm #220260In reply to: How to title with the taxonomy name
AnonymousInactiveYes,
I’m trying to figure it out. But all what I try it also removes the term.
Like, if it is “activity: ski jobs” it ends with “jobs”
Using this code:
<?php echo $sf_current_query->get_field_string(“_sft_activities”); ?> jobs
Thank you in advance!
September 4, 2019 at 11:32 am #220252In reply to: How to title with the taxonomy name
AnonymousInactiveOk got it:
<?php echo $sf_current_query->get_field_string(“_sft_activities”); ?> jobs
But it displays like this activities: ski jobs
How can I remove the “activities:”
Thanks again for your time!
September 4, 2019 at 11:28 am #220250In reply to: How to title with the taxonomy name
AnonymousInactiveThanks for the response.
I’ve done that but it doesn’t work:
<?php
//grab the active query from our search form
//replace1526with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(3959)->current_query();
?>
<h1 class=”hjobs”><?php echo $sf_current_query; ?> jobs</h1><br>What am I doing wrong?
Thanks!
August 30, 2019 at 2:07 pm #220031In reply to: Display No Result If No Search String Entered
TrevorParticipantFrom your original code I would have had this:
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: these templates are not full page templates, rather * just an encaspulation of the your results loop which should * be inserted in to other pages by using a shortcode - think * of it as a template part * * This template is an absolute base example showing you what * you can do, for more customisation see the WordPress docs * and using template tags - * * http://codex.wordpress.org/Template_Tags * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(233)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { if ( $query->have_posts() ) { ?> <?php while ($query->have_posts()) { $query->the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"> <h2><?php the_title(); ?></h2> <?php if( get_field('summary_portfolio_description') ): ?> <p><?php the_field('summary_portfolio_description'); ?></p> <?php endif; ?> <?php the_excerpt(); ?> </a> </article> <?php } } else { echo "<span id='no-results'>No results found, please try altering your search criteria.</span>"; } } ?>August 29, 2019 at 4:14 pm #219973In reply to: Display No Result If No Search String Entered
AnonymousInactiveHi Trevor,
Thanks for the prompt reply, I’ve amended my results.php file as per your suggestion on that other post but I think I’ve done something wrong as no results show now.
This is my code:
if ( $query->have_posts() ) { ?> <?php global $searchandfilter; $sf_current_query = $searchandfilter->get(233)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { ?> Results code here. <?php} } ?>Any ideas where I’m going wrong with this?
Thanks,
James
-
AuthorSearch Results
-
Search Results
-
Topic: Accessing the Search Data
I want to do some custom formatting depending on the used filters… I tried this:
global $searchandfilter;
$sf_current_query = $searchandfilter->get(69991)->current_query();
echo $sf_current_query->get_fields_html(
array(“_sfm_mk_quelle_affiliate_shop”),
$args
);… and: echo $sf_current_query->get_field_string(“_sfm_mk_quelle_affiliate_shop”);
And took the field name from my search url:
https://miriamkreativ.de/material?_sfm_mk_quelle_affiliate_shop=Creativ-DiscountBut there is nothing shown unfortunately…
I tried one more thing (displaying the searchg term):
global $searchandfilter;
$sf_current_query = $searchandfilter->get(69991)->current_query();
echo $sf_current_query->get_search_term();… and this works for me. So please can you help me with the first example, showing / getting the chosen “affiliate shop”-option?