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

Support archive

Low_Search: Search term within a specific month & year filter

NIall O'Brien 16 Jan 2015 17:23 question, complete

I'd like to search for all entries of a specific collection for a specific month of a year as set by the entry_date.
Eg. User inputs search query, dropdown selects a collection, dropdown selects a month and dropdown selects a year.

How can I easily filter for these results?

I need to add the month and year dropdowns to this form: http://pastebin.com/RMTF597E and somehow get these selections to filter the result.

Thanks in advance.

Replies

  1. Low 16 Jan 2015 17:44

    You could use the native year / month params for that: https://ellislab.com/expressionengine...

  2. NIall O'Brien 19 Jan 2015 09:11

    Thanks, but how do I pass the values from the form to the results template using low_search?

  3. Low 19 Jan 2015 09:19

    Same you would any parameter in Low Search. Eg:

    <select name="year">
    <option value="2015">2015</option>
    <option value="2014">2014</option>
    <option value="2013">2013</option>
    ...
    </select>
    <select name="month">
    <option value="1">January</option>
    <option value="2">February</option>
    <option value="3">March</option>
    ...
    </select>
    You could use Low List to help out generate those options.

  4. NIall O'Brien 19 Jan 2015 09:24

    Thanks, it's not clear from the documentation how to do this. How do I then access these values in the results page?

  5. Low 19 Jan 2015 09:35

    Well, the docs explain the principle of using parameters in LS rather than giving an example of every possible parameter. Apart from the parameters made available by the filters, all native parameters that belong to the channel:entries tag are available, too. That includes the year/month parameters.

    So, according to the principle, this:

    {exp:low_search:results year="2015" month="1"}


    is equal to this:

    <input name="year" value="2015"> 
    <input name="month" value="1">


    ...inside the Form tag, making the values dynamic and part of the (encoded) query.

    The value of the params can be outputted with:

    {low_search_year} 
    {low_search_month}


    ...inside the Form, Filters and Results tags.

    Make sense?

  6. NIall O'Brien 19 Jan 2015 10:43

    That makes perfect sense, thank you very much.