Forums Forums Search & Filter Pro How to set a title for every search

Viewing 10 posts - 1 through 10 (of 10 total)
  • Anonymous
    #117477

    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”

    Trevor
    #117628

    Hi

    What Display Results method are you using?

    Are you using Ajax to refresh the results?

    Anonymous
    #118853

    Yes. I am using Ajax for the results page

    Trevor
    #118884

    Hi Nick, what about my other question, ‘What Display Results method are you using?’

    Anonymous
    #118896

    So sorry, as a displayresult method I am using “as an archive”

    Trevor
    #118898

    Are you using a template PHP file for the results (maybe modified by you) OR a template PHP file that you have written?

    With Ajax ON, the S&F form will have an Ajax Container defined (default is #main, but many themes have this differently, so you need to check) and the code for the title has to be placed within this Ajax Container. That means that the title must also be inside this container. Note that the form should NOT be inside this container.

    Anonymous
    #118900

    I have used my template. and the results are showing perfectly. The container is #ajaxcontainer and it is set in the roem attributes. The form is not in the container. So when I add a <?php the_title(); ?> outside the #ajaxcontainer i get nothing! when I adden it inside the #ajaxcontainer I get the title of the first post received from the search.

    What I need is a page title “search result for genre: Jazz” and then all my products

    Trevor
    #118904

    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.

    Anonymous
    #118995

    ok. That worked when i added the title inside the ajax results container.

    Is it possible to also change values in other parts of the page depending on the filter selection?

    What I want to achieve is
    I have a main filter and then some secondary filters… I wan to load different secondary filters depending the selection of the first filter. IS this possible

    Thanks in advance

    Trevor
    #119037

    I imagine it could be possible, but only with some serious custom coding. What you could do is write some javascript that watches for our Ajax to finish (see our FAQ page for code examples) and use that to then maybe trigger changes elsewhere on the page.

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