2

I'm building a Low Search form to filter channel entries by Solspace Tag GROUP fields. I have installed Low Search Tag (http://github.com/low/low_search_tag) but it looks like my only options are filtering by individual tags, ex:

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

But I need a similar select dropdown in my form showing the Solspace Tag GROUPS.

CHANNEL FIELDS: Each Tag GROUP belongs in its own channel field (screenshot).

enter image description here

What name="" attribute do I need for a similar dropdown of Tag Groups so that if a Tag Group is selected, entries with at least one tag in the selected Tag Group will be included in search results?

1

I can't answer for Low Search, but you can use a query to get a list of tag groups:

<select name="i_dont_know_for_low_search">
{exp:query sql="SELECT * FROM exp_tag_groups"}
    <option value="{tag_group_id}">{tag_group_name}</option>
{/exp:query}
</select>

Ignoring Low Search for an instant, if you were using a regular HTML form and POST variables (or a plugin such as Mo'Variables to get POST values of a submitted form), for example, you could then use PHP to create a string of pipe-delimited tags using {exp:tag:tags} and the tag_group_id that you selected.

Then, put this string of tags in {exp:tag:entries} to get a list of entries based on the selected tag group.

1
  • This is a very interesting approach, thank you for the insight Solspace! Sep 19 '13 at 3:58
1

I've replied to your email already, but will repeat here for visibility.

In short, you want a single dropdown that contains custom fields that in turn relate to tag groups. You want to see if the selected field is not empty. The tricky part is that usually, Low Search fields will target field values, not the fields themselves.

Low Search can target specific fields or global entry data. You're looking to see if field A, B or C is not empty (has tags). Normally, that would be accomplished with search:field_a="not IS_EMPTY", search:field_b="not IS_EMPTY" etc, which translates into:

<input name="search:field_a" value="not IS_EMPTY">
<input name="search:field_b" value="not IS_EMPTY">
etc.

The name parameter targets the field, the value parameter targets the value. Same with <select> elements. This means you can't use a single drop down for multiple fields, unless you use javascript to change the name="" parameter of the select-element. For example:

<select name="">
    <option value="not IS_EMPTY" data-field="search:field_a">Field A</option>
</select>

Add an onchange event to the <select> to read out the data-field="" attribute to change the name="" attribute of the <select>.

1
  • Thanks Low, you are a gentleman and a scholar, a man among men, and my hero. Sep 19 '13 at 3:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.