Forums Forums Search Search Results for 'sf_current_query'

Viewing 10 results - 211 through 220 (of 318 total)
  • Author
    Search Results
  • #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”

    #116180

    Trevor
    Participant

    Hi

    You need to make sure that you have followed the Customization guide here.

    Edit the results.php file like this (where 1234 is changed for the actual ID of your form):

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1234)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      // any other message here if no search has been made (can be empty)
    } else {
      // your results.php code here
    }
    #109934

    Anonymous
    Inactive
     while ( $sf_current_query->have_posts() ) : $sf_current_query->the_post();
      $index = $sf_current_query->current_post + 1; ?>
      section:nth-child(<?php echo $index; ?>) > .category {
      background:url('<?php the_post_thumbnail_url('large'); ?>');
      box-shadow: inset 0px 0px 400px 110px rgba(0, 0, 0, .7);
    }
    <?php endwhile;
    #108703

    Anonymous
    Inactive

    GOT IT!!!

    global $searchandfilter;
    
     $sf_current_query = $searchandfilter->get(504)->current_query()->get_array();
    
     if (empty($sf_current_query)) {
        echo ('All Articles');
        }
     else {
       echo $sf_current_query['_sft_category']['active_terms'][0]['name'];
     }

    The above code worked like a charm, I also use the “Archive” setting as you suggested! Thanks so much for your help on this one!! Finally working properly!! 🙂

Viewing 10 results - 211 through 220 (of 318 total)