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

Support archive

Including filter by 2 categories

Daniel Brinnand 19 Jun 2012 12:46 question, complete

Is it possible to search by 2 categories, for example:

Categories
{exp:channel:categories channel="my_channel" style="linear"}

{category_name}

{/exp:channel:categories}

Categories
{exp:channel:categories channel="my_channel" style="linear"}

{category_name}

{/exp:channel:categories}

Thanks in advance

Dan

Replies

  1. Daniel Brinnand 19 Jun 2012 12:49

    Sorry just to make it clearer.

    What I want to do is to check against 2 categories (from the same channel). For example - sub category location & sub category price

    Thanks

    Dan

  2. Low 19 Jun 2012 12:56

    Hi Dan,

    That is possible. If you're using two select-elements for the two category options, make sure both elements have the name="category[]" attribute. Then, in the low_search:form tag, add the require_all="category" parameter.

    See also the docs about the require_all parameter.

  3. Daniel Brinnand 19 Jun 2012 13:17

    Thanks for the prompt reply - very impressive support!

    I think I have done what you suggest and it is not picking up both options, it just returns no results

    See below

    {exp:low_search:form query="{segment_3}" require_all="category"}
    Categories -select name="category[]"-
    {exp:channel:categories channel="members" style="linear"}
    -option value="{category_id}"{if category_id IN ({low_search_category})} selected="selected"{/if}-
    {category_name}
    -/option-
    {/exp:channel:categories}
    -/select-

    Categories -select name="category[]"-
    {exp:channel:categories channel="members" style="linear"}
    -option value="{category_id}"{if category_id IN ({low_search_category})} selected="selected"{/if}-
    {category_name}
    -/option-
    {/exp:channel:categories}
    -/select-
    -button type="submit"-Search-/button-
    {/exp:low_search:form}

  4. Daniel Brinnand 19 Jun 2012 13:18

    Note I have put - so code is not removed...

  5. Low 19 Jun 2012 13:26

    That looks good. Can you enable template debugging and look up the lines that mention Low Search, when viewing the search results page after submitting the form? Perhaps make a screenshot of it and post it here.

    I'd also like to see the code for the search results tag.

    Pro tip: if you're sharing code here, you could use a service like http://pastie.org since GetSat messes things up, as you discovered.

  6. Daniel Brinnand 19 Jun 2012 13:49

    Template debugging:
    (0.022390 / 10.26MB) Low Search: No search, just filter entries by given parameters
    (0.022877 / 10.27MB) Low Search: Calling the channel module

    Search Tag
    {exp:low_search:results query="{segment_3}" limit="10"}
    {title}
    {if count == 1}

      {/if}
      -li--a href="{comment_url_title_auto_path}"-{title}-/a--/li-
      {if count == total_results}-/ol-{/if}
      {if no_results}No search results{/if}
      {/exp:low_search:results}

  7. Low 19 Jun 2012 13:52

    Okay, then I take it you have entries that have both categories applied to them? Status open, not expired or entry date in the future?

    If not, could you send me Super Admin login credentials for your installation so I can take a look myself? You can send the info to hi at gotolow dot com.

  8. Daniel Brinnand 19 Jun 2012 14:04

    I am a complete numpty. I hadn't selected the correct cats!

    Thank you for all your support and your amazing plug-in - I will give you 5 stars on devot:ee.

    Thanks again (and sorry to waste your time)

    Dan

  9. Low 19 Jun 2012 14:06

    You're welcome, Sir. Glad you got it to work.