-
AuthorSearch Results
-
November 17, 2016 at 4:37 pm #70903
In reply to: Settings & Default / Post (wrong default order)
AnonymousInactiveHi,
thanks for your help!!!
It wasn’t the wpml plugin,
but the custom code (that I was sure it wasn’t in cause)
I had to add the bold section here to make it workfunction sf_filter_query_args( $query_args, $sfid ) { if($sfid==1225){ global $searchandfilter; $sf_current_query = $searchandfilter->get(1225)->current_query(); $sf_current_query->get_field_string("_sfm_event_archives"); $_sfm_event_archives_array = $sf_current_query->get_array(); $archive_is_check = $_sfm_event_archives_array[_sfm_event_archives][active_terms][0][value]; //print_r($archive_is_check); if($archive_is_check != '1'){ $args_custom = array( <strong>"meta_key" => "imic_event_start_dt", "orderby" => "meta_value_num", "order" => "ASC",</strong> "meta_query" => Array ( "event_archives" => Array ( "key" => "event_archives", "value" => "0" ) ) ); $query_args = array_merge($query_args, $args_custom); } // si aucun filtre d'appliqué //if($sf_current_query->is_filtered()!=1){} } return $query_args; } add_filter( 'sf_edit_query_args', 'sf_filter_query_args', 100, 2 );
Thanks again for your help guys!
Really nice plugin!November 16, 2016 at 2:55 pm #70563In reply to: Get date range from current archive.php url
AnonymousInactiveTrevor,
Between this and another support post that I located, this was indeed the solution:
$sarr = $sf_current_query->get_array();
$fromDate = $sarr[_sf_post_date][active_terms][0][value] ;
$toDate = $sarr[_sf_post_date][active_terms][1][value];Thanks!
July 26, 2016 at 3:11 pm #52218In 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 🙁
April 21, 2016 at 5:04 pm #43565In reply to: How to style the search data
AnonymousInactiveHi,
I’ve added the code but it seems to be throwing an error on the array. Am I missing something?
<?php
//Get a multiple fields values by passing an array of field names
//replace1526
with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(339)->current_query();
echo $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false)
);
?>I’ve also added the code from the supplied link but it throws back the following error:
array(2) { [“_sft_length”]=> array(5) { [“name”]=> string(13) “Yacht Lengths” [“singular_name”]=> string(12) “Yacht Length” [“all_items_label”]=> string(17) “All Yacht Lengths” [“type”]=> string(8) “taxonomy” [“active_terms”]=> array(1) { [0]=> array(4) { [“id”]=> int(6) [“name”]=> string(6) “40-50m” [“value”]=> string(6) “40-50m” [“count”]=> int(5) } } } [“_sft_toy”]=> array(5) { [“name”]=> string(15) “Yacht Hero Toys” [“singular_name”]=> string(14) “Yacht Hero Toy” [“all_items_label”]=> string(19) “All Yacht Hero Toys” [“type”]=> string(8) “taxonomy” [“active_terms”]=> array(1) { [0]=> array(4) { [“id”]=> int(16) [“name”]=> string(7) “Freezer” [“value”]=> string(7) “freezer” [“count”]=> int(5) } } } }Found on the same web link as before.
March 17, 2016 at 5:54 pm #39703In reply to: Display search terms other than category do not work
AnonymousInactiveI finally found this solution:
$sarr = $sf_current_query->get_array();
$author = $sarr[authors][active_terms][0][name] ;
$fromDate = $sarr[_sf_post_date][active_terms][0][value] ;
$toDate = $sarr[_sf_post_date][active_terms][1][value];I hope it keeps on working always!
March 17, 2016 at 5:08 pm #39701In reply to: Display search terms other than category do not work
AnonymousInactiveHi!
Sorry for my late reply but I had to complete another project..
If I do a var_dump I get the following:
array(2) { [“authors”]=> array(5) { [“name”]=> string(7) “Authors” [“singular_name”]=> string(6) “Author” [“all_items_label”]=> string(11) “All Authors” [“type”]=> string(9) “post_type” [“active_terms”]=> array(1) { [0]=> array(3) { [“id”]=> int(39) [“name”]=> string(7) “Agenzie” [“value”]=> string(7) “agenzie” } } } [“_sf_post_date”]=> array(1) { [“active_terms”]=> array(2) { [0]=> array(1) { [“value”]=> string(8) “01032016” } [1]=> array(1) { [“value”]=> string(8) “16032016” } } } }In my form I have Authors (in this example value for that is “Agenzie”) and Post Date range fields.
I am not expert in PHP…can you help me to get the authors and post date range?
As $sf_current_query->get_field_string(“authors”) does not work.Thanks
-
AuthorSearch Results