Forums Forums Search Search Results for 'sf_current_query'

Viewing 10 results - 281 through 290 (of 318 total)
  • Author
    Search Results
  • #52078

    In reply to: Getting value from url


    Trevor
    Participant

    This?

    <?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(15)->current_query();
    	print_r($sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false)));
    ?>
    #52076

    In reply to: Getting value from url


    Trevor
    Participant

    I see the error. My bad for copying and pasting. The forum has changed the quotes 🙁

    <?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(15)->current_query();
    	print_r $sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false));
    ?>

    Or, I hope that is it.

    #52072

    In reply to: Getting value from url


    Anonymous
    Inactive

    If I use this code:

    <?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(15)->current_query();
    	print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false));
    ?>

    It “breaks” the page…?

    #52071

    In reply to: Getting value from url


    Trevor
    Participant

    I need to see the array structure to know which element to grab. This code instead of the current echo should give the array:

    print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false));
    
    #51940

    In reply to: Getting value from url


    Anonymous
    Inactive

    <?php echo $sf_current_query->get_fields_html(array("_sft_aantal_personen","_sft_arrangementstype","_sft_type_boot","_sft_type_boot_2","_sft_boot_opties"), array('show_all_if_empty' => false)); ?>

    This…

    #51933

    In reply to: Getting value from url


    Anonymous
    Inactive

    Hi Trevor,

    I think it’s this part:

    <?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(15)->current_query();
    ?> 
    
    <?php $arrangement = $sf_current_query->get_fields_html(array("_sft_aantal_personen","_sft_arrangementstype","_sft_type_boot"), array('show_all_if_empty' => false)); ?>

    I like to keep my echo’s separate from the rest… so I can echo them where ever I like.

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

    #51738

    Trevor
    Participant

    Hi

    I found two errors (one was ours, one yours), so here is the fixed code (I do not know if this will work):

    <?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
     *
     */
    
    if ( $query->have_posts() ) {
        global $searchandfilter;
        $sf_current_query = $searchandfilter->get(44)->current_query();
        if ($sf_current_query->is_filtered()) {
            ?>
    
            <?php echo $query->found_posts; ?> Firm(s) Meet All Selected Criteria<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>
                    <h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>
    
                    <p><?php the_tags(); ?></p>
    
                </div>
    
                <hr/>
                <?php
            }
            ?>
    
            <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 firms meet all of your criteria. Try unchecking some boxes.";
        }
    }
    ?>
    #46964

    Anonymous
    Inactive

    got it! here is the solution.

    <?php
    	             global $wp_query;
    	             $sf_current_query = $wp_query->query_vars['_sft_position']; ?>
    						   <?php if (isset ($sf_current_query))  :  ?>
    						<?php 
                   echo '<span class="results-term">' . $sf_current_query . '</span>';
    							 
    							?> 
    						   <?php endif; ?>

    the vars can be changed to any search term you have.

    #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 />';
        }
      }
    ?>
Viewing 10 results - 281 through 290 (of 318 total)