Forums Forums Search Search Results for 'sf_current_query'

Viewing 10 results - 251 through 260 (of 318 total)
  • Author
    Search Results
  • #83207

    Anonymous
    Inactive

    oh and again

    global $searchandfilter; 
    $sf_current_query = $searchandfilter->get(1530)->current_query();

    doesnt return anything when selecting parent taxonomy, only when selecting taxonomy post is assigned to.

    #80210

    Trevor
    Participant

    There were a couple of errors in that, so I have re-coded it (I am not sure about the do_shortcode bit, but I have left that as is):

    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Results Template
     * 
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2015 Designs & Code
     * 
     * Note: these templates are not full page templates, rather 
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think 
     * of it as a template part
     * 
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs 
     * and using template tags - 
     * 
     * http://codex.wordpress.org/Template_Tags
     *
     */
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(3552)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
    		echo "make your selection";
    } else {
    	if ( $query->have_posts() )
    {
    	echo '<div class="row">';
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		?>
    			<div class="col-md-3 popmake-<?php the_ID();?>" data-do-default="" style="cursor: pointer;">
    				<h3 style="text-align: center;"><?php the_title(); ?></h3>
    				<p style="text-align: center;"><?php do_shortcode(the_excerpt()); ?></p>
    			</div>
    	<?php
    	echo '</div>';
    	}
    }
    else
    {
    	echo 'No Results Found';
    }
    }
    ?>

    That may make no difference, but give it a try.

    #80206

    Anonymous
    Inactive

    shure!

    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Results Template
     * 
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2015 Designs & Code
     * 
     * Note: these templates are not full page templates, rather 
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think 
     * of it as a template part
     * 
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs 
     * and using template tags - 
     * 
     * http://codex.wordpress.org/Template_Tags
     *
     */
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(3552)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
    		echo "make your selection";
    } else {
    	if ( $query->have_posts() )
    {
    	echo "<div class=\"row\">";
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		?>
    			<div class="col-md-3 popmake-<?php the_ID();?> data-do-default="" style="cursor: pointer;">
    				<h3 style="text-align: center;"><?php the_title(); ?></h3>
    				<p style="text-align: center;"><?php do_shortcode(the_excerpt()); ?></p>
    			</div>
    	<?php
    	echo "</div>";
    	}
    }
    else
    {
    	echo "No Results Found";
    }
    }
    ?>

    Trevor
    Participant

    Marjan, we seem to have successfully coded up the solution for this, using a PHP snippet:

    <?php
      global $searchandfilter;
      $sf_query = $searchandfilter->get(3217)->current_query();
      if ($sf_query->is_filtered()) {
        $sf_current_query = $searchandfilter->get(3217)->current_query()->get_array();
        echo "<b>Prikaz rezultatov za...</b>";
        $cat_string = "";
        foreach($sf_current_query['_sft_category']['active_terms'] as $item) {
          $cat_string .= $item['name'] . ", ";
        }
        $starost_string = "";
        foreach($sf_current_query['_sfm_starost']['active_terms'] as $item) {
          $starost_string .= $item['name'] . ", ";
        }
    if (($sf_current_query['_sft_category']['active_terms'][0]['name'])<>"") echo "<div>PRODUKTI: " . substr($cat_string, 0, -2) . "</div>";
    if (($sf_current_query['_sft_post_tag']['active_terms'][0]['name'])<>"") echo "<div>STANJA: " . ($sf_current_query['_sft_post_tag']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name'])<>"") echo "<div>KAKOVOST SPREMEMBE: " . ($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_starost']['active_terms'][0]['name'])<>"") echo "<div>STAROST: " . substr($starost_string, 0, -2) . "</div>";
    if (($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name'])<>"") echo "<div>VRSTA PRIMERA: " . ($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name']) . "</div>";
    }
    ?>

    So I will close this now. Great to speak with you on Skype.

    #79193

    Trevor
    Participant

    OK, if you have followed the documentation to make a copy of the results.php into a new folder called search-filter in your child theme or theme folder, then replace the contents of that template file with this (change the number 255 for the ID number of your search form and change the line echo '<div>Nothing to see here folks!</div>'; for whatever you want before the filter is used instead of the results – or remove for nothing at all):

    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Results Template
     * 
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2015 Designs & Code
     * 
     * Note: these templates are not full page templates, rather 
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think 
     * of it as a template part
     * 
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs 
     * and using template tags - 
     * 
     * http://codex.wordpress.org/Template_Tags
     *
     */
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(255)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
    	
    	if ( $query->have_posts() )
    {
    	?>
    	
    	Found <?php echo $query->found_posts; ?> Results<br />
    	Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
    		<?php
    			/* example code for using the wp_pagenavi plugin */
    			if (function_exists('wp_pagenavi'))
    			{
    				echo "<br />";
    				wp_pagenavi( array( 'query' => $query ) );
    			}
    		?>
    	</div>
    	
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    		<div>
    			<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			
    			<p><br /><?php the_excerpt(); ?></p>
    			<?php 
    				if ( has_post_thumbnail() ) {
    					echo '<p>';
    					the_post_thumbnail("small");
    					echo '</p>';
    				}
    			?>
    			<p><?php the_category(); ?></p>
    			<p><?php the_tags(); ?></p>
    			<p><small><?php the_date(); ?></small></p>
    			
    		</div>
    		
    		<hr />
    		<?php
    	}
    	?>
    	Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
    		<?php
    			/* example code for using the wp_pagenavi plugin */
    			if (function_exists('wp_pagenavi'))
    			{
    				echo "<br />";
    				wp_pagenavi( array( 'query' => $query ) );
    			}
    		?>
    	</div>
    	<?php
    }
    else
    {
    	echo "No Results Found";
    }
    }
    ?>

    Trevor
    Participant

    OK, nearly there. This is the code we have so far:

    <?php
      global $searchandfilter;
      $sf_query = $searchandfilter->get(3217)->current_query();
      if ($sf_query->is_filtered()) {
    ?>
    <div>Found <?php echo $sf_query->found_posts; ?> Results</div>
    <?php
      $sf_current_query = $searchandfilter->get(3217)->current_query()->get_array();
    if (($sf_current_query['_sft_category']['active_terms'][0]['name'])<>"") echo "<div>KATEGORIJE: " . ($sf_current_query['_sft_category']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sft_post_tag']['active_terms'][0]['name'])<>"") echo "<div>OZNAKE: " . ($sf_current_query['_sft_post_tag']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name'])<>"") echo "<div>KAKOVOST SPREMEMBE: " . ($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_starost']['active_terms'][0]['name'])<>"") echo "<div>STAROST: " . ($sf_current_query['_sfm_starost']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name'])<>"") echo "<div>VRSTA PRIMERA: " . ($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name']) . "</div>";
    }
    ?>

    And we know that the only part NOT working is:

    <div>Found <?php echo $sf_query->found_posts; ?> Results</div>
    
    #73970

    Anonymous
    Inactive

    Hey Trevor,

    Managed to figure it out.

    For the record here’s what I used (replacing 725 with whatever your specific search ID is..)

    <?php

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(725)->current_query();

    $array_data = $sf_current_query->get_array();
    $typeOfSearch = $array_data[“_sf_sort_order”][“active_terms”][0][“value”];

    echo $typeOfSearch ;

    ?>

    Keith

    #73321

    Anonymous
    Inactive

    Hi, we were able to get the meta values we needed with get_array();

    And for those curious the code we used was (square-feet is our custom field):

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(315)->current_query();
    
    $array_data = $sf_current_query->get_array();
    $squarefeet_min = $array_data["_sfm_square-feet"]["active_terms"][0]["value"];
    $squarefeet_max = $array_data["_sfm_square-feet"]["active_terms"][1]["value"];
    ?>

    Thanks again for the help.

    #70909

    Anonymous
    Inactive

    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(
    “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 );

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

Viewing 10 results - 251 through 260 (of 318 total)