Search Results for 'current_query'

Forums › Forums › Search › Search Results for 'current_query'

Viewing 10 results – 201 through 210 (of 385 total)
  • Author
    Search Results
  • #178123

    In reply to: Get Count of Filters


    Trevor
    Participant

    Please 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.

    #178015

    Anonymous
    Inactive

    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);
    
    #177706

    Trevor
    Participant

    With 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-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
    }
    #176841

    Trevor
    Participant

    Are 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.

    #176709

    Anonymous
    Inactive

    That 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.

    #176626

    Trevor
    Participant

    As 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.

    #176590

    Trevor
    Participant

    Instead 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);
    ?>
    #176578

    Anonymous
    Inactive

    Follow 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?


    Trevor
    Participant

    This 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).


    Trevor
    Participant

    It 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).

Viewing 10 results – 201 through 210 (of 385 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.