Forums Forums Search Search Results for 'current_query'

Viewing 10 results - 231 through 240 (of 344 total)
  • Author
    Search Results

  • Anonymous
    Inactive

    Hi Trevor,

    Thanks for the reply, I found the solution:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1274)->current_query()->get_array();
    foreach($sf_current_query as $key) {
    	echo '<span>' . $key['value'] . ' ' . $key['name'] . ' ' . $key['active_terms'][0]['name'] . ', </span>'; 
    	}	

    Anonymous
    Inactive

    Hi,

    I am trying to use this code in the results.php file:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1274)->current_query();
    $searchTerm = $sf_current_query->get_search_term();
    echo $searchTerm;

    but I get no results

    #122756

    In reply to: Category Description


    Anonymous
    Inactive

    Yeah that works thanks.

    How do I combine the $sf_current_query,true

    with

    $currentCat = $sf_current_query['_sft_project_category']['active_terms'][0]['id'];
    
    #122566

    In reply to: Category Description


    Trevor
    Participant

    It is my code creating the 1. D’oh

    Replace this:

    echo '<pre>',print_r($sf_current_query),'</pre>';
    

    with this:

    echo '<pre>',print_r($sf_current_query,true),'</pre>';
    

    The reason is that the 1 is confirmation that a result was returned. This is because print_r does this by default if you echo it. Adding the true parameter stops it doing that.

    I am unsure why your original adds the 1 though.

    #122348

    In reply to: Category Description


    Trevor
    Participant

    Can you use this code to print out the query:

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(119)->current_query()->get_array();
    echo '<pre>',print_r($sf_current_query),'</pre>';
    ?>
    #122346

    Trevor
    Participant

    The first thing to do is to be able to print to your page the current query (which is an array), and do a few searches to see what the data looks like, when the category is set, and when it is set to ALL. You would do this using the PHP print_r function, so a quick search for snippets on this forum later …

    See if this prints your query out:

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(2051)->current_query()->get_array();
    echo '<pre>',print_r($sf_current_query),'</pre>';
    ?>
    #122324

    In reply to: Category Description


    Anonymous
    Inactive

    Okay I’ve worked out how to obtain the ID and get the description but the ID has an extra 1 at the end of the string which I’ve had to strip off.

    Can you see why it would have the extra one and how to avoid it?

    Thanks

    		<?php global $searchandfilter;
    			$sf_current_query = $searchandfilter->get(119)->current_query()->get_array();
    			$currentCat = $sf_current_query['_sft_project_category']['active_terms'][0]['id'];
    			$currentCatID = rtrim($currentCat,'1');
    			echo category_description( $currentCatID );
    		 ?>
    #121294

    Trevor
    Participant

    Custom CSS and javascript. There are snippets posted on the forum in many threads, but what you will need depends a lot on your particular needs and site/theme.

    Showing ‘current filters’ is very difficult and requires some considerable skill in coding, but can be done. If you search on the forum for sf_current_query you will see some snippets using one of our filters.

    #118904

    Trevor
    Participant

    Instead of <?php the_title(); ?> use

    <?php echo "<h1>Search result(s) for genre: " . $sf_current_query->get_field_string("_sft_genre") . "</h1>;"; ?>
    

    Or similar.

    #117477

    Anonymous
    Inactive

    Hello,

    this is a great plugin but i can’t figure out one thing. Is is possible to change the title of the page in any given search.

    I mean when the results are loading with Ajax aso change the titlte of the page for example is user is searching for a custom field named genre and the term is rock I need on ajax to change the title of the page to “search result for genre:Rock”, if the user searches for term Jazz, then the title of the page will be “search result for genre: Jazz”

    I tried using

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(123)->current_query();
    echo $sf_current_query->get_field_string(“_sft_genre”);

    but this only returns the initial genre, it doesn’t change if the user changes the filter “genre”

Viewing 10 results - 231 through 240 (of 344 total)