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

Support archive

Reset a search form when not encoding queries

outline4 9 Mar 2016 20:23 question, complete

Hi Low,

I am using Low Search for the first time without encoding the query.

I have two different exp:low_search:form(s) and want to combine the results.

When the query was encoded I could use the query parameter and either set it to "" or the segment where the query is. This would result in either combining the queries or not...

somehow this is missing with the non encoded counterpart.
with low_search:url I can set reset='yes', but there seems nothing for the form itself?

So basically I am looking for a reset parameter in the query form...

Thanks
Stefan

I am on EE 2.8.1 and Low Search 4

Replies

  1. Low 10 Mar 2016 07:27

    Indeed, there is no reset="yes" for the Form tag, and any search query that is present in the query string will be automatically set for the Results, Form, Filters and URL tags.

    For the Form tag, this would only matter if you use conditionals to pre-populate certain values. You could use the {current_query_string} variable in those conditionals to check if there is indeed a query in the URL.

  2. outline4 10 Mar 2016 10:13

    In fact the form does NOT take into account any query string parameters that are present in the url.

    But with the remember parameter I could tell it to include certain values from the query string:

     

    {exp:low_search:form remember="category:marke|category:haupt" result_page="shop"}
    <aside class="cat_group">
    <label>Preisspanne</label><br />
    <select name="store:price">
    <option value="|10"{if "{get:store:price}" == "|10" } selected="selected"{/if}>bis CHF 10</option>
    <option value="10|25"{if "{get:store:price}" == "10|25" } selected="selected"{/if}>CHF 10 bis 25</option>
    <option value="25|50"{if "{get:store:price}" == "25|50" } selected="selected"{/if}>CHF 25 bis 50</option>
    <option value="50|100"{if "{get:store:price}" == "50|100" } selected="selected"{/if}>CHF 50 bis 100</option>
    <option value="100|"{if "{get:store:price}" == "100|" } selected="selected"{/if}>CHF 100 und mehr</option>
    </select>
    <input type="submit" value="->" />
    </aside>
    {/exp:low_search:form}



    So I guess for this situation I am setteled. I was confused that only the contrary of reset is available on forms. Maybe this is because it's low search store?

    Cheers
    Stefan

    Low 10 Mar 2016 14:02

    The form should automatically have the parameters set. Just make sure you follow this principle; so to use the value of a parameter called 'store:price' in the form, use the variable {low_search_store:price}.

  3. outline4 10 Mar 2016 10:18

    While I am at it... Just a quick side question:

    For query strings: Is it possible to work with category_url_titles instead of category_id's..

    Something like:

    {low_search:url reset='yes' result_page='shop' category:haupt='{category_url_title}'} 


    instead of

    {low_search:url reset='yes' result_page='shop' category:haupt='{category_id}'}
    ?

    Low 10 Mar 2016 14:03

    That won't work, no; it works identically to the native category="" parameter, which only accepts IDs.

    outline4 10 Mar 2016 14:08

    yes sorry... It just accepts ID's... sadly... is there no workaround to be able to use category_url_titles?

    Low 10 Mar 2016 14:10

    Well, if you're using URL segments, you can use Low Seg2Cat to make the translation for you.That or a custom extension to convert the url_titles to IDs, using the low_search_pre_search hook.

    outline4 10 Mar 2016 14:15

    Since I am using query strings, I cannot use low Seg2Cat. It would be very nice if there was a String2Cat plugin... but well... how else could it be? Coming back to EE from craft and working with categories is a really really frustrating... nothing works as expected and getting just some basic category stuff without add-ons seems impossible... well... but using low search with query strings is actually quite nice... :)

    Low 10 Mar 2016 14:18

    This might help you, then: https://devot-ee.com/add-ons/cat2

    outline4 10 Mar 2016 14:23

    Oh... yes... that's nice! but then when using multiple categories combined I would run into trouble again... well then... I feel like it's 1997 again :) no worries!