Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Accessing the Search Data

Viewing 2 posts - 1 through 2 (of 2 total)
  • Miriam Brückner
    #222988

    I want to do some custom formatting depending on the used filters… I tried this:
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(69991)->current_query();
    echo $sf_current_query->get_fields_html(
    array(“_sfm_mk_quelle_affiliate_shop”),
    $args
    );

    … and: echo $sf_current_query->get_field_string(“_sfm_mk_quelle_affiliate_shop”);

    And took the field name from my search url:
    https://miriamkreativ.de/material?_sfm_mk_quelle_affiliate_shop=Creativ-Discount

    But there is nothing shown unfortunately…

    I tried one more thing (displaying the searchg term):

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

    … and this works for me. So please can you help me with the first example, showing / getting the chosen “affiliate shop”-option?

    Trevor Moderator
    #223002

    To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. This thread might help you:

    https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/

    … and this search will give similar threads I think:

    https://support.searchandfilter.com/forums/search/sf_current_query+get_array

    Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.

    You could temporarily use this code in your results template to display the full filter array so that you can work out the exact array part that holds the data you want:

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

    Where the ID needs to match that of your form.

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

You must be logged in to reply to this topic.