-
AuthorSearch Results
-
November 17, 2016 at 4:38 pm #70909
In reply to: Settings & Default / Post (wrong default order)
AnonymousInactivefunction 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(
“meta_key” => “imic_event_start_dt”,
“orderby” => “meta_value_num”,
“order” => “ASC”,
“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 );November 17, 2016 at 4:37 pm #70903In 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 🙁
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!
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
-
AuthorSearch Results