-
AuthorSearch Results
-
January 8, 2018 at 2:45 pm #151119
In reply to: Refresh the active query object with AJAX filtering
AnonymousInactivehaha yes. That makes total sense, and it’s working as expected now. I was testing the output at the top of the file without thinking about where the results refresh…
One more thing… I would like to wrap the label and term in markup. Is there a way to return the label and term values separately?
For instance,echo $sf_current_query->get_field_string("_sft_location");returns “Location: Africa”, but I would like it to read<dt>Location:</dt><dd>Africa</dd>.Thanks!
December 14, 2017 at 9:06 pm #147706In reply to: Taxonomy Breadcrumbs
AnonymousInactiveFor clarity, this is what I used:
global $searchandfilter; $sf_current_query = $searchandfilter->get(339)->current_query()->get_array(); foreach($sf_current_query as $key) { echo '<div>' . $key['active_terms'][0]['name'] . '</div>'; }November 15, 2017 at 11:20 am #142055In reply to: Manually get results
TrevorParticipantI am not entirely certain what you are doing with this, but WordPress needs to post the query to a page, which you could then use this to grab the query array:
$sf_current_query = $searchandfilter->get(7050)->current_query()->get_array();Where you change the ID to the form ID of your form.
November 10, 2017 at 4:25 am #141086In reply to: Some Ui questions
AnonymousInactiveok, great help over skype Trevor – exactly what i was after and pretty much all sorted – thanks!
for anyone interested
1. use pre and print r instead of var dump to get the bits you need:
$sf_current_query = $searchandfilter->get(7050)->current_query(); echo '<pre>'; print_r($sf_current_query->get_array()); echo '</pre>';2. I ended up with this in my page template to target the ACF meta name chosen in the S&F query – i also ended up trying to cope with the All values parts being sent if no specific options are selected (i hide all items selection in front end):
global $searchandfilter; $sf_current_query = $searchandfilter->get(7050)->current_query()->get_array(); if ($sf_current_query['_sfm_comfort']['active_terms'][0]['name'] == ""){ echo 'no preference for comfort'; } else { echo '$sf_current_query['_sfm_comfort']['active_terms'][0]['name'] . ' comfort'; }November 7, 2017 at 7:53 am #140420In reply to: Some Ui questions
AnonymousInactiveHi Trevor, got a little further with styling so thanks for that. One thing with accessing the search data so I can display what’s been searched for – i’ve looked at
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
but am not getting any output. I’m using ACF meta fields for all the search criteria so maybe I need to use something differently?
?_sfm_comfort=medium&_sfm_value_judgement=bestquality&_sfm_state=wa
is the query stringi’m using this in the custom page template:
echo $sf_current_query->get_fields_html(
array(“_sfm_comfort”)
);echo $sf_current_query->get_field_string(“_sfm_comfort”);
also doesn’t give any result.
the var dump gives:
array(3) { [“_sfm_comfort”]=> array(5) { [“name”]=> string(0) “” [“singular_name”]=> string(0) “” [“all_items_label”]=> string(0) “” [“type”]=> string(9) “post_meta” [“active_terms”]=> array(1) { [0]=> array(2) { [“name”]=> string(6) “Medium” [“value”]=> string(6) “medium” } } } [“_sfm_value_judgement”]=> array(5) { [“name”]=> string(0) “” [“singular_name”]=> string(0) “” [“all_items_label”]=> string(0) “” [“type”]=> string(9) “post_meta” [“active_terms”]=> array(1) { [0]=> array(2) { [“name”]=> string(12) “Best Quality” [“value”]=> string(11) “bestquality” } } } [“_sfm_state”]=> array(5) { [“name”]=> string(0) “” [“singular_name”]=> string(0) “” [“all_items_label”]=> string(0) “” [“type”]=> string(9) “post_meta” [“active_terms”]=> array(1) { [0]=> array(2) { [“name”]=> string(2) “WA” [“value”]=> string(2) “wa” } } } }help appreciated – cheers
MikeOctober 6, 2017 at 9:19 am #135079In reply to: Hide items until filter is checked
TrevorParticipantYou would need to do some custom coding. There are many examples in this forum. Such as this:
They all have the keyword
sf_current_query
in them.
October 3, 2017 at 5:12 pm #134617In reply to: Post date search not working as expect
AnonymousInactiveI have resolved the issue by inserting a To of today’s date before the ajax request is submitted and also got the current_query array to output correctly.
Am I right in thinking you don’t currently have any checks in place to ensure a To and From date are set before submitting?
September 15, 2017 at 8:41 am #131197In reply to: How do I get the form fieldvalues?
TrevorParticipantThe first thing then is to find what the array (data) looks like after you submit a search (with values in those two fields). Into whichever results template you are using, I need you to add this PHP code (before the loop runs), and it will print out the array of data to your screen, which you can then post back here within code ticks (the backwards quote mark that is on the key normally to the left of the main keyboard ‘1’ key, one before the code and one after it):
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(12345)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query,true),'</pre>'; ?>Where I have used
12345, you need to replace that for the ID of your form.August 14, 2017 at 10:18 am #125885In reply to: sf_edit_query_args does not change the search
TrevorParticipantThe first thing to do is, in the code, before you make a change, use the PHP
print_rfunction to output the query array to the screen, and that, after you modify it, do the same again, and compare the arrays. Like this:echo '<pre>',print_r($sf_current_query,true),'</pre>';I have not actually used the sf_edit_query_args function myself.
August 14, 2017 at 8:59 am #125881Topic: sf_edit_query_args does not change the search
in forum Search & Filter Pro
AnonymousInactiveHi there I recently followed the example https://support.searchandfilter.com/forums/topic/null-fields-not-returning-results/ as I have an identical issue.
I used this code pretty much verbatim and a print_r shows all the range fields have been removed from $sf_current_query, HOWEVER the search still behaves as though they are still there and is returning 0 results. If I manually edit the search URL it works fine.
How do I make sf_edit_query_args actually change the search?
Thanks,
Caroline
-
AuthorSearch Results
-
Search Results
-
Hi there I recently followed the example https://support.searchandfilter.com/forums/topic/null-fields-not-returning-results/ as I have an identical issue.
I used this code pretty much verbatim and a print_r shows all the range fields have been removed from $sf_current_query, HOWEVER the search still behaves as though they are still there and is returning 0 results. If I manually edit the search URL it works fine.
How do I make sf_edit_query_args actually change the search?
Thanks,
Caroline