-
AuthorSearch Results
-
May 17, 2018 at 7:25 am #178123
In reply to: Get Count of Filters
TrevorParticipantPlease note that, as your license has expired, you will first need to renew at the (discounted) renewal price to receive support.
Does this code show anything different?
$sf_current_query_array = $searchandfilter->get(1446)->current_query()->get_array(); echo '<pre>'; print_r($sf_current_query_array); echo '</pre>';You will need to change the ID number of course. There are some threads on the forum that you can search for where other users have used this code to access the filters data.
May 16, 2018 at 6:26 pm #178015Topic: Get Count of Filters
in forum Search & Filter Pro
AnonymousInactiveHow can I count the number of filters being output programmatically?
I’ve tried the following and can see the data, but can’t access the private attributes.
$sf_current_query = $searchandfilter->get($sf_id)->current_query(); var_dump($sf_current_query);May 15, 2018 at 5:20 pm #177706In reply to: Page Reset – Issues????
TrevorParticipantWith our Shortcode method, in the documentation link I gave you, is the guide to customising.
Once you have a copy of the results.php file in a
search-filtersub-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 }May 10, 2018 at 2:11 pm #176841In reply to: Displaying results on load
TrevorParticipantAre you using our shortcode display results method? If so, edit the results.php file to use code 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).
Make sure you are working on a copy of the results.php file in a search-filter sub-folder of your theme/child theme folder, and not the original in our plugin template folder.
May 9, 2018 at 5:03 pm #176709In reply to: How do display the category in results?
AnonymousInactiveThat didn’t work but the one from the link you provided earlier did work.
Here’s the code:
global $searchandfilter; $sf_current_query = $searchandfilter->get(71131)->current_query(); $args = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); $result_title = $sf_current_query->get_fields_html( array("_sft_ld_course_category"), $args );Thank you for your help with this.
May 9, 2018 at 10:12 am #176626In reply to: Hide results list by default
TrevorParticipantAs you are if you are using our shortcode display results method (and therefore our results.php template file), it needs to be edited to 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).
Make sure you are working on a copy of the results.php file in a search-filter sub-folder of your theme/child theme folder, and not the original in our plugin template folder.
May 9, 2018 at 6:08 am #176590In reply to: How do display the category in results?
TrevorParticipantInstead do this I think:
<?php $args = array( "str" => '%2$s', "show_all_if_empty" => false ); echo $sf_current_query->get_field_html(array("_sft_ld_course_category"),$args); ?>May 9, 2018 at 2:19 am #176578In reply to: How do display the category in results?
AnonymousInactiveFollow up:
The string that is returned for this:
<?php echo $sf_current_query->get_field_string("_sft_ld_course_category"); ?>(ld_course_category is the course category for the learndash lms plugin)
is:
Course Categories: All Course Categories
Is there a way the to get rid of the “Course Categories:” portion of the string so I’m just left with the actual result?
May 8, 2018 at 11:57 am #176320
TrevorParticipantThis would depend on the layout template being used for your page. That would depend on your theme or page builder/content plugin that you are using, or, if you are using our shortcode display 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).
May 7, 2018 at 11:22 am #176099
TrevorParticipantIt does indeed make sense. Here is how you would code what you want to do:
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).
-
AuthorSearch Results
Search Results for 'current_query'
-
Search Results
-
Topic: Get Count of Filters
How can I count the number of filters being output programmatically?
I’ve tried the following and can see the data, but can’t access the private attributes.
$sf_current_query = $searchandfilter->get($sf_id)->current_query(); var_dump($sf_current_query);