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

Support archive

Filtering results

Dan Treasure 11 Feb 2014 11:50 question, complete

Hi Low, first up I just want to say I have loved all of your plugins that I have had the opportunity to use!

Quick question about Low Search. I'm trying to work out if Low Search or Reefine (http://devot-ee.com/add-ons/reefine) will best suit my clients needs and requirements. Ideally I want to use Low since I have used Reorder, Low Variables, and am about to use Events shortly.

I currently have two clients from different industries that require a "search filter" within their site.

Client A is a real estate website that wants to give users the ability to filter the current properties that are for sale by price, the property type, number of bedrooms etc.

Client B is a community website that wants to give their users the ability to filter upcoming events with a selection of filtering options (similar to above - just not property related).

Can and is Low Search an good fit for these requirements? How easy is it to integrate with an already existing set of channel entries? Eg. property channel with 200 entries - can I retrofit Low Search to give the users their filtering ability?

I look forward to hearing from you!
Dan

Replies

  1. Low 11 Feb 2014 11:57

    Hi Dan,

    Great to hear you're liking my add-ons!

    Looking at your descriptions, Low Search shouldn't have any trouble at all tackling the filtering options of both sites. In fact, I know that there are other real estate sites running Low Search with similar requirements.

    If you combine Low Search with Low Events, you can even use LS to filter LE entries, too. Also, implementing LS into an existing site with content is no problem at all, especially if you already have your channel fields set up in a good way (avoiding a single text field for all combined details like price, type, etc -- those should be separate fields, which I'm sure they are).

  2. Dan Treasure 11 Feb 2014 12:53

    SOLD!

    Thanks heaps for your swift reply and for answering my question!

    I'm excited to get started using LS! I'm assuming everything I need is in your documentation?

    Thanks again,
    Dan

  3. Low 11 Feb 2014 13:03

    Should be, yes. Be sure to read the chapter on Parameters. And feel free to ask away if you need help.

  4. Dan Treasure 11 Feb 2014 13:05

    Great, thanks heaps Low!

  5. Dan Treasure 15 Mar 2014 02:30

    Hi Low,

    I've purchased LS and have read through the docs but I am struggling big time - maybe I'm having an off day but I cannot work-out or see in the docs how I can retro-fit the LS functionality into my existing channel.

    I tried manipulating the example (which appears to be a dedicated search page) but that threw errors ...

    Basically I have a standard EE channel {exp:channel:entries channel="property" limit="5" category="1" disable="member_data" paginate="bottom"} and each piece of data - number of beds, rooms, baths, land size etc are their own individual fields. How can I set up LS to have filtering functionality like a standard real estate website?

    Sorry if this is a basic question - I just feel like I've hit a brick wall.

  6. Low 15 Mar 2014 11:07

    Okay, I’ll try and explain.

    Consider the native channel:entries tag. You can get to a specific entry, or set of entries, by specifying parameters. For example, this:

    {exp:channel:entries channel="property" limit="5" category="1" disable="member_data" paginate="bottom"}

    ...will give you entries from the Property channel and category 1, 5 entries per page. You can add more parameters to be more specific. For example:

    {exp:channel:entries channel="property" search:beds="3" search:land_size="200" limit="5" category="1" disable="member_data" paginate="bottom"}

    Will give you the same as the first, but also limited to 3 beds and a land size of 200, using the search:field_name parameters.

    The more parameters you specify, the more specific the returned entries will be. In essence, you're filtering and searching entries by setting any of the native parameters.

    Back to Low Search. The Results tag works identically to the native channel:entries tag: it filters down entries based on the given parameters. But apart from all native channel:entries parameters, you can also use any of the parameters made available by Low Search's Filters. That means you can do something like this:

    {exp:low_search:results channel="property" range:beds="2|4" range:land_size="150|300" limit="5" category="1" disable="member_data" paginate="bottom"}

    Instead of the native search:field_name parameter, we're using the Ranges filter to get entries with 2 to 4 beds and a land size of 150 to 300.

    You can add as many parameters and use as many filters as you want. The Keywords filter, for example:

    {exp:low_search:results collection="property" keywords="beautiful" range:beds="2|4" range:land_size="150|300" limit="5" category="1" disable="member_data" paginate="bottom"}

    Now, we're also filtering entries by keywords, so only entries that match the search term "beautiful" are returned. Note that using the Keywords filter requires setting up Collections.

    So, in short: the more parameters you specify, the more specific your search results will be.

    But of course, you don't want to hard-code all these parameters. Instead, you want the user to define their values. That is why, in Low Search, you can use any parameter as an input field in your search form. The form will encode the parameters into a single search query, and puts it in the URI. The results tag can then read this query (using the query="") parameter, decode it, and it will set the parameters automatically.

    For example, say the keywords need to be flexible. Then create a form like this:

    {exp:low_search:form result_page="search/results"} 
    <input type="search" name="keywords">
    <button type="submit">Search</button>
    {/exp:low_search:form}


    This form will redirect you to a URI like domain.com/search/results/QUERY where the last segment contains the encoded query. Therefore, in the search/results template, you can put a Results tag, like this:

    {exp:low_search:results query="{segment_3}" collection="property" range:beds="2|4" range:land_size="150|300" limit="5" category="1" disable="member_data" paginate="bottom"}

    Now, instead of having hard-coded the keywords parameter, we're using a search form, which contains an input field with name="keywords", to make the keywords parameter dynamic. Just remember to define the query="" parameter in the Results tag, so Low Search can read the encoded query.

    Let's move some more parameters to the search form:

    {exp:low_search:form result_page="search/results"} 
    <input type="search" name="keywords">
    <select name="range:beds">
    <option value="">Select number of beds</option>
    <option value="1|2">1 - 2</option>
    <option value="2|4">2 - 4</option>
    <option value="4|8">4 - 8</option>
    </select>
    <select name="range:land_size">
    <option value="">Select land size</option>
    <option value="50|150">50 to 150</option>
    <option value="150|300">150 to 300</option>
    <option value="300|600">300 to 600</option>
    </select>
    show <select name="limit">
    <option>5</option>
    <option>10</option>
    <option>25</option>
    <option>50</option>
    </select> per page
    <button type="submit">Search</button>
    {/exp:low_search:form}


    So we can remove them from the Results tag:

    {exp:low_search:results query="{segment_3}" collection="property" category="1" disable="member_data" paginate="bottom"}

    Now we've moved both Ranges and even the limit parameter to the form, so you can select how many beds, the land size, and even let the user decide how many search results per page he/she wants to see.

    Make sense?

    Noor Mohammad 15 Nov 2016 07:06

    Lodewijk Schutte is a legend!

  7. Dan Treasure 22 Jun 2014 03:12

    Thank you so much Low for your clear and descriptive explanation!

    I have now been able to set-up the filtering form and results page (which is awesome!).

    I was going to ask you how to increase the functionality for the user by allowing them to select a min & max price range (using separate selection options) but was able to easily work it out with your awesome documentation using "range-from" & "range-to":

    <label for="sf_minprice">Min-price</label>
    <select name="range-from:p_price" id="sf_minprice">
    <option value="0">$0</option>
    <option value="100000">$100,000</option>
    <option value="200000">$200,000</option>
    <option value="300000">$300,000</option>
    <option value="400000">$400,000</option>
    <option value="500000">$500,000</option>
    <option value="600000">$600,000</option>
    <option value="700000">$700,000</option>
    </select>

    <label for="sf_maxprice">Max-price</label>
    <select name="range-to:p_price" id="sf_maxprice">
    <option value="200000">$200,000</option>
    <option value="300000">$300,000</option>
    <option value="400000">$400,000</option>
    <option value="500000">$500,000</option>
    <option value="600000">$600,000</option>
    <option value="700000">$700,000</option>
    <option value="800000">$800,000</option>
    <option value="900000">$900,000</option>
    <option value="1000000">$1,000,000</option>
    </select>

    LEGEND - thank you so much for your help & support!

    Cheers,
    Dan

  8. Martin Pedemonte 8 Feb 2016 08:24

    thanks low for taking the time to explain filtering in a "newbie" way. I was needing something like this to go on. You should publish a few articles like this one as part of documentation.

    Don't get me wrong, documentation is great. However, LS cappabilites are insane, so someone like me can find them overwhelming to start with.

    In my case, I've been working with EE for 10 years; and I still have some conceptual issues i need to refresh from time to time... So, articles like this help me a lot.

    Thanks & sorry for the offtopic!