Forums Forums Search & Filter Pro How to output the type of search done

  • This topic has 5 replies, 2 voices, and was last updated 8 years ago by Anonymous.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #73929

    Hi guys,

    Looking for some help echoing the type of search done in my search.php file.

    I have a search that uses “Sort Order” and it searches for posts four different ways – by date ascending and descending, and by two different custom values.

    On my search page I wish to display a heading like “Results – Latest Posts” (eg for “Date Descending”) or “Results – Oldest Posts” (eg for “Date Descending”) …and so on for the other two searches.

    How do I do this?

    Many thanks,

    Keith

    Trevor
    #73958
    Anonymous
    #73968

    Hey Trevor,

    Thanks for the reply. However I’m not sure if what’s in that thread is exactly what I’m looking for..

    Here’s my site below, the search is when you scroll down to “podcast episodes” and there’s a dropdown list named “view posts by:”)

    http://lbl.pearldesign.ie/

    When I conduct one of the different searches, here are the URLs..

    http://lbl.pearldesign.ie/results-of-search/?sort_order=date+desc
    http://lbl.pearldesign.ie/results-of-search/?sort_order=date+asc
    http://lbl.pearldesign.ie/results-of-search/?sort_order=_sfm_featured-checkbox+desc+num
    http://lbl.pearldesign.ie/results-of-search/?sort_order=_sfm_views+desc+num

    What I’m looking for is to be able to tap into the “sort order” values so that I simply output a heading for each different page which says something like “Results by: xxx” based upon what the “sort order” is.

    Any ideas on how to do this? Not sure if what’s described on that thread is what I need (though could be wrong there..)

    Keith

    Anonymous
    #73970

    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

    Trevor
    #74039

    Hi Keith

    I am glad you got that sorted 🙂

    Is this thread ready to be closed?

    Anonymous
    #74058

    Sure thing Trevor, please close….and many thanks for your support, much appreciated 🙂

    Keith

Viewing 6 posts - 1 through 6 (of 6 total)