Forums Forums Search Search Results for 'sf_current_query active_terms'

Viewing 10 results - 41 through 50 (of 50 total)
  • Author
    Search Results
  • #70903

    Anonymous
    Inactive

    Hi,
    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 work

    
    function 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!

    #70563

    Anonymous
    Inactive

    Trevor,

    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!

    #52218

    In reply to: Getting value from url


    Anonymous
    Inactive

    Well, 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>';
    } ?>
    #52114

    In reply to: Getting value from url


    Trevor
    Participant

    What 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>';
    }
    #51898

    In reply to: Getting value from url


    Anonymous
    Inactive

    Hi 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?

    #46959

    Trevor
    Participant

    OK

    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 />';
        }
      }
    ?>
    #43915

    Trevor
    Participant

    Ok.

    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 🙁

    #43565

    Anonymous
    Inactive

    Hi,

    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
    //replace 1526 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.

    #39703

    Anonymous
    Inactive

    I 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!

    #39701

    Anonymous
    Inactive

    Hi!
    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

Viewing 10 results - 41 through 50 (of 50 total)