-
AuthorSearch Results
-
May 12, 2017 at 12:19 am #108367
In reply to: How to show the currently selected title only
TrevorParticipantYou would need to dig deeper in the
$sf_current_queryarray I suspect. You can echo the array to a page with a PHP print_r function inside pre tags.May 11, 2017 at 7:24 pm #108331In reply to: How to show the currently selected title only
AnonymousInactive<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(504)->current_query(); echo $sf_current_query->get_field_string("_sft_category"); ?>The above code gets the current category, but how to do it without the extraneous word(s) before it?
Thanks
April 26, 2017 at 7:04 pm #105034In reply to: visibility of reset button
TrevorParticipantHi
You could use PHP to see if the results are filtered, like this (change the ID number for yours):
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if (($sf_current_query->is_filtered())||($sf_current_query->get_search_term()!="")) { // do something that identifies a search has been made (set some CSS, ...) } // your normal template code hereApril 19, 2017 at 6:52 pm #103879Topic: Initial Results
in forum Search & Filter Pro
AnonymousInactiveHey!
So the post “Customize initial results” was really helpful, however is it possible to display a random list of results where “// your holding template code here” is at?
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // your holding template code here } else { // your normal template code here }Thanks!
April 19, 2017 at 9:26 am #103704In reply to: Customize initial results
TrevorParticipantIf you have access to the PHP template files, you can use something like this (change the ID for your form ID):
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // your holding template code here } else { // your normal template code here }April 8, 2017 at 4:36 pm #102134In reply to: Customizing result page
TrevorParticipantWith the shortcode method, the URL re-write is not possible (it is possible only with The Post Type Archive/WooCommerce Display Results Method). This is a feature planed for V3 (being written now, release later in 2017).
You can access the current query by adding code to the results.php file.
I am unable to code this for you, but if you search the forum for this string
sf_current_query, you will find some examples.March 22, 2017 at 5:44 pm #98807In reply to: Null Fields Not Returning Results
AnonymousInactiveWooo, that got it. Thank you for your patience.
For anyone else with this issue please see my code below. Probably not perfect but it works. 🙂
// Exclude the default range values from the search as they are meaning the search returns no results function remove_default_range( $query_args, $sfid ) { //if search form ID = 225, the do something with this query if($sfid==25 && $query_args) { if((isset($query_args['meta_query']))&&(is_array($query_args['meta_query']))) { global $searchandfilter; $sf_current_query = $searchandfilter->get(25)->current_query()->get_array(); /* echo "<pre>"; print_r($sf_current_query); echo "</pre>";*/ echo $sf_current_query['_sfm_minimum_per_round'][0]['value']; if($sf_current_query['_sfm_minimum_per_round'][0]['value'] == '0' && $sf_current_query['_sfm_minimum_per_round'][0]['value'] == '50000') { unset($sf_current_query['_sfm_minimum_per_round']); } if($sf_current_query['_sfm_minimum_per_season'][0]['value'] == '0' && $sf_current_query['_sfm_minimum_per_season'][0]['value'] == '1000000') { unset($sf_current_query['_sfm_minimum_per_season']); } } } return $query_args; } add_filter( 'sf_edit_query_args', 'remove_default_range', 20, 2 );March 22, 2017 at 4:54 pm #98769In reply to: Null Fields Not Returning Results
TrevorParticipantIt is a while since I looked at the array, but I think I did something like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(25)->current_query()->get_array(); echo "<pre>"; print_r($sf_current_query); echo "</pre>";March 17, 2017 at 12:35 pm #97498In reply to: Search and filter issues
TrevorParticipantThis is not so easy, as it would the use of PHP around that grid, and I do not think VC can do that. This is how that is done in PHP:
You can show them nothing (or a custom message) using this type of PHP code (change the number 1234 for the ID number of your search form and change the line echo ‘<div>Nothing to see here folks!</div>’; for whatever you want before the filter is used instead of the results – or remove for nothing at all):
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your VC Grid here }As I say, I am not sure how you can do that though.
March 10, 2017 at 2:36 pm #95975In reply to: Accessing the Search Data
AnonymousInactiveI found some workaround, to display currently selected value:
$tmp = $sf_current_query->get_array(); echo $tmp["_sfm_character"]["active_terms"][0]["name"];But it may be a bug in
get_field_stringmethod from documentation, which is not working in my case:echo $sf_current_query->get_field_string("_sfm_character"); -
AuthorSearch Results
-
Search Results
-
Topic: Initial Results
Hey!
So the post “Customize initial results” was really helpful, however is it possible to display a random list of results where “// your holding template code here” is at?
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { // your holding template code here } else { // your normal template code here }Thanks!