All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

How do I output search terms in results page?

IC360 14 Nov 2019 17:46 question, complete

Sorry if I'm being thick, but how do I output the search terms (from custom fields) on the Results page?

My search form:
{exp:low_search:form result_page="clients/search-results" channel="clients"}
     <input type="text" name="search:client-firstname" value="" />
{/exp:low_search:form}

My results page:
{exp:low_search:results query="{segment_3}"}
     {low_search_client-firstname}
{/exp:low_search:results}

Replies

  1. Low 15 Nov 2019 19:34

    This page in the docs should help you with that.

  2. IC360 19 Nov 2019 07:49

    Hi Low,
    I have looked at that Docs page, and I think I have coded it correctly, but please correct me. I need to display the searched values in the search form again on the Results page:

    {exp:low_search:form channel="clients" result_page="clients/search-results"}
         <input type="text" name="search:client-firstname" value="{low_search_client-firstname}" placeholder="First name" />
    {/exp:low_search:form}

    At the moment, the search itself works fine, but the above input field only displays the placeholder text.

  3. Low 19 Nov 2019 07:53

    Okay, so the rule is: to output param_name use variable {low_search_param_name}.

    If you apply this to search:client-firstname, then use the variable {low_search_search:client-firstname}.

    Also, make sure the Form tag has a query="" param, like the Results tag, so it knows what query was submitted.

  4. IC360 20 Nov 2019 09:54

    All sorted. :-)
    Here's my solution for a Search form, which is also displayed on the Search Results page. The form fields show the current Search terms, or the Placeholder text if that field isn't used.
    There is also a Relationship field included, called 'projects'.

    {exp:low_search:form query="{segment_3}" result_page="clients/search-results" channel="clients"} 
    <input type="text" name="search:title" value="{low_search_search:title}" placeholder="Client ID" />
    <input type="text" name="search:client-firstname" value="{low_search_search:client-firstname}" placeholder="First name" />
    <input type="text" name="search:client-surname" value="{low_search_search:client-surname}" placeholder="Surname" />
    <input type="text" name="search:client-town" value="{low_search_search:client-town}" placeholder="Town" />
    <select name="child:client-projects">
    <option value=""></option>
    {exp:channel:entries channel="projects" orderby="title" sort="asc" dynamic="no"}
    <option value="{entry_id}" {if entry_id == low_search_child:client-projects}selected="selected"{/if}>{title}</option>
    {/exp:channel:entries}
    </select>
    <button type="submit">Search</button>
    {/exp:low_search:form}


    Thanks for your help.