Forums Forums Search Search Results for 'sf_current_query'

Viewing 10 results - 111 through 120 (of 318 total)
  • Author
    Search Results

  • Trevor
    Participant

    I need to know if you have this set as shown here:

    https://www.screencast.com/t/jVW9z2FJ

    If it is, then the results.php needs to be modified like this (where I have used the ID number of your form):

    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.php code here
    }

    Make sure any files you modify are in the child theme folder (if you copy our results.php file, it needs to be in a sub-folder of the child theme, called search-filter, not our plugin folder or a parent theme folder). Do NOT edit the copy of results.php that is in our plugin templates folder, as it will be overwritten by updates.

    #211828

    Trevor
    Participant

    The third line would be:

    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {

    So the first do something is if nothing has been searched.


    Trevor
    Participant

    You would have to couple that with a test to see if the page is filtered. I am not sure of the code, but it would be something like this (replace the 12345 with the ID of the form):

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(12345)->current_query();
    if ((!$sf_current_query->is_filtered()) .....

    That might work.

    #211140

    Anonymous
    Inactive

    I have another topic regardless this one.
    For example, my search query have custom taxonomy named “product_type”.
    I’m using this line to retrive what kind of “product_type” is retrived right now:
    $searchProductType = $sf_current_query->get_field_string("_sft_product_type");

    However, is there any option to get ID of searched taxonomy instead of “Product Type: Name” ?

    #210744

    Trevor
    Participant

    To showing the filters, this requires custom coding when using the current version of Search & Filter Pro. You can access the filter terms though, but would need further PHP work to display them. To 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+field+%5Bvalue%5D/

    Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.


    Trevor
    Participant

    As you are using our Shortcode Display Results method, then the results.php needs to be modified like this (where I have used the ID number of your form):

    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.php code here
    }

    Make sure any files you modify are in the child theme folder (if you copy our results.php file, it needs to be in a sub-folder of the child theme, called search-filter, not our plugin folder or a parent theme folder). Do NOT edit the copy of results.php that is in our plugin templates folder, as it will be overwritten by updates.

    I am not sure what you mean by #2? Is the page URL you have given me not the default search page, or do you mean the one your theme uses?

    #209353

    Trevor
    Participant

    Instead of this:

    echo $sf_current_query->get_fields_html(array("_sft_category"), $args);

    this:

    $my_category_array = $sf_current_query->get_fields_html(array("_sft_category"), $args);

    And then manipulate, I think. For this you would need to find some snippets, on a site like stackexchange.

    #209339

    Anonymous
    Inactive

    Thank you so much. Now Im displaying the result counter also Im displaying the filters.

    <?php		
    		global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(840)->current_query();
    		$args = array(
    				"str" 					=> '%2$s', 
    				"delim" 				=> array(", ", " - "), 
    				"field_delim"				=> ', ', 
    				"show_all_if_empty"			=> false 
    			);
    			
    			echo $sf_current_query->get_fields_html(
    				array("_sft_category"), 
    				$args
    			);
    
    ?>

    My result is

    Genre1, Genre2, Genre3, etc…

    How I can “put” this array in div or class?

    #209333

    Trevor
    Participant

    I am sorry for the delay. I am working my way through a backlog and I answer posts is oldest last touched order, so yours was still another two or three down the list when you sent that last reply. The standard WordPress would, with your wp_query() array name, look like this:

    Found <?php echo $query_all->found_posts; ?> Results

    As to showing the filters, this is more complex. It would require custom coding when using the current version of Search & Filter Pro. You can access the filter terms though, but would need further PHP work to display them. To 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+field+%5Bvalue%5D/

    Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.

    #209306

    Trevor
    Participant

    It would require custom coding when using the current version of Search & Filter Pro. You can access the filter terms though, but would need further PHP work to display them. To 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+field+%5Bvalue%5D/

    Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.

Viewing 10 results - 111 through 120 (of 318 total)