-
AuthorSearch Results
-
July 26, 2016 at 3:11 pm #52218
In reply to: Getting value from url
AnonymousInactiveWell, that breaks the code, the part where the echo should be doens’t show anymore. The rest doesn’t show neither.
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(15)->current_query()->get_array(); foreach($sf_current_query as $key) { echo '<div>' . $key['name'] . '</div>'; echo '<div>' . $key['active_terms'][0]['name'] . '</div>'; } ?>
July 25, 2016 at 3:49 pm #52114In reply to: Getting value from url
TrevorParticipantWhat does this give?
global $searchandfilter; $sf_current_query = $searchandfilter->get(339)->current_query()->get_array(); foreach($sf_current_query as $key) { echo '<div>' . $key['name'] . '</div>'; echo '<div>' . $key['active_terms'][0]['name'] . '</div>'; }
July 22, 2016 at 9:41 am #51898In reply to: Getting value from url
AnonymousInactiveHi Trevor, I got it to work.
Using this code:function refresh() { $('.things').load(document.URL + ' .things'); } //detects the start of an ajax request being made $(document).on("sf:ajaxstart", ".searchandfilter", function(){ console.log("ajax start"); }); //detects when the ajax request has finished and the content has been updated // - add scripts that apply to your results here $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); //so load your lightbox or JS scripts here again refresh(); }); //an event fired when S&F is initialised and S&F scripts have been loaded $(document).on("sf:init", ".searchandfilter", function(){ console.log("S&F JS initialised"); });
The only thing is, it posts the whole category and name: Aantal personen: 20 of meer personen. You’ve already tackelled this problem here: https://support.searchandfilter.com/forums/topic/how-to-style-the-search-data/
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>'; }
Which would display “20 of meer personen” but What I would like is to have it show “Aantal personen:<br />20 of meer personen.
What to do?
May 29, 2016 at 10:20 am #46959In reply to: displaying search terms without labels
TrevorParticipantOK
I have re-written that a bit and added a new line after each line output. It may not work, but it is better code:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(2327)->current_query()->get_array(); if (isset ($sf_current_query)) { foreach($sf_current_query as $key) { echo '<span class="results-term">' . $key['active_terms'][0]['name'] . '</span><br />'; } } ?>
April 26, 2016 at 10:44 am #43915In reply to: How to style the search data
TrevorParticipantOk.
So, this is the code I made:
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>'; }
If you wanted to put the X before each, replace the echo line with something like this:
echo '<div><a id="executeMyCodeLink" href="#">X</a> ' . $key['active_terms'][0]['value'] . '</div>';
Where the code to add to the page would be something like this
<script> $('#executeMyCodeLink').click(function(event) { /// Your code here }); </script>
But that is beyond the scope of what I can do easily 🙁
January 28, 2016 at 6:00 pm #35604In reply to: Display post meta from search field.
RossKeymasterwhat happens if you var_dump the array:
<?php //Get a single fields values using labels //replace 1526 with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(147)->current_query(); var_dump($sf_current_query->get_array()); ?>
CAn you paste the output here?
Thanks
December 10, 2015 at 10:58 pm #31935In reply to: Different templates for different filter search
AnonymousInactiveSo I’ve been trying to pull the field name from the Active Query Object, but I’m not able to pull any of custom fields, just categories.
I’m able to get _sft_credit_card_category, but not the post_meta fields of _sfm_issuer and _sfm_credit_quality.
<?php //grab the active query from our search form global $searchandfilter; $sf_current_query = $searchandfilter->get(615)->current_query(); var_dump($sf_current_query->get_array()); echo $sf_current_query->get_field_string("_sft_credit_card_category"); echo $sf_current_query->get_field_string("_sfm_issuer"); echo $sf_current_query->get_field_string("_sfm_credit_quality"); ?>
November 24, 2015 at 5:35 pm #30635In reply to: Date not always showing
AnonymousInactiveHey Ross,
Did you try it on the results.php located in the avada theme folder /search-filter ?
I tried this again with the following two codes;
<?php
//Get an array of objects containing data for the current search/filter
//replace1526
with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(14458)->current_query();
var_dump($sf_current_query->get_array());
?>and
<?php
//Get a single fields values using labels
//replace1526
with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(14458)->current_query();
echo $sf_current_query->get_field_string(“_sft_category”);?>
Neither are able to pull the values I need.
I’d like to turn the Categories In: line to not be bulleted and be on the same line. If I can pull the category then it would be fine.
I tried the above codes at the top of the results.php and neither worked.
Any idea why ?
October 9, 2015 at 2:35 pm #26959In reply to: How to get search terms
AnonymousInactiveJust an update.
I tried to use following code but it seems that a function does not exists:<?php
//Get an array of objects containing data for the current search/filter
//replace1526
with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1526)->current_query();
var_dump($sf_current_query->get_array());
?>ERROR: Fatal error: Call to a member function get() on a non-object in …
-
AuthorSearch Results