0

I'd like to set up Low Search to only search category names and tags. I haven't been able to figure out a way to combine Low Search and Low Search Tag to just return results from category and tag names.

I have two category groups: Topics (group_id="2") and Audiences (group_id="11").

There are currently 282 tags set by the client using Solspace Tag 4.1.1. (group_name="default") (group_id="1")

Here's my most current attempt:

{exp:low_search:form 
    collection="speakers" 
    search_mode="all" 
    result_page="search/results"}
{exp:tag:cloud tag_group_name="default"}

  <input type="text" class="text" name="keywords" id="textbox"  style="width:135px;" />

  {/exp:tag:cloud}
{/exp:low_search:form}

...and my results page

{exp:low_search:results
    tag_id="default"
}
  ...
{/exp:low_search:results}

I'm not sure if I should be nesting the low_search and low_search_tag tag pairs within each other. Any help would be appreciated.

I'm using:

-- EE 2.5.5 -- Low Search 2.4.0 -- Solspace Tag 4.1.1

0

Low Search will always return Entries. The Results tag basically is the same as the channel:entries tag, but with added filters, including an advanced category filter and Solspace Tag filter, when used with Low Search Tag. It does not return the categories or tags themselves.

So, to filter by category and/or tags, follow the examples in the Low Search docs and Low Search Tag docs. The search results will only have entries that have the selected categories/tags assigned to them.

Also, note that Low Search Tag doesn't have tags itself, it just adds the ability to Low Search to filter by Solspace Tag, using these parameters.

Here's a crude example:

Search Form

{exp:low_search:form
    result_page="search"
    query="{segment_2}"
    require_all="category"
}

    Select topic
    <select name="category[]">
        <option value="">All</option>
        {exp:channel:categories channel="speakers" category_group="2" style="linear"}
            <option value="{category_id}"{if category_id IN ({low_search_category})} selected="selected"{/if}>
                {category_name}
            </option>
        {/exp:channel:categories}
    </select>

    Select audience
    <select name="category[]">
        <option value="">All</option>
        {exp:channel:categories channel="speakers" category_group="11" style="linear"}
            <option value="{category_id}"{if category_id IN ({low_search_category})} selected="selected"{/if}>
                {category_name}
            </option>
        {/exp:channel:categories}
    </select>

    Select tag
    <select name="tag_id[]" multiple="multiple">
        {exp:tag:cloud tag_group_name="group1"}
            <option value="{tag_id}"{if tag_id IN ({low_search_tag_id})} selected="selected"{/if}>
                {tag}
            </option>
        {/exp:tag:cloud}
    </select>

    <button type="submit">Search!</button>

{/exp:low_search:form}

Search Results

{exp:low_search:results
    query="{segment_2}"
    status="not closed"
    disable="member_data|category_fields"
}
    ...
{/exp:low_search:results}

In summary, this contains:

  • A single select for Topic;
  • A single select for Audience;
  • A multiple select for Tag;
  • require_all="category" will make sure only results with both selected categories are returned (so Topic A and Audience X, instead of Topic A or Audience X).
  • The search results will contain entries that match any of the selected tags. To change that to all, add tag_id to the require_all parameter, thus: require_all="category|tag_id".

If you want to be able to select multiple topics and audiences (so get results from Topic A, B, or C and Audience X, Y, or Z), use the Category Groups option.

| improve this answer | |
  • Hi Low - Thanks for taking the time to answer my question. I now understand that Low Search doesn't return the tags or categories themselves, but the Entries that contain them. Your second paragraph is a bit confusing to me though. (you can filter. read the docs.) How do I combine Low Search and Low Search Tag to filter the results? There is no example of this in the docs (or I'm overlooking it). Do they even need to be combined? (maybe I'm overthinking it?). Do you have an example of where this has been done before? I'll read through the docs some more. Thanks again for your time. – user94 Aug 31 '13 at 17:51
  • Updated my answer with an example for you. – Low Sep 1 '13 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy