0

I have two category groups. One is for Towns and the other is for Designations. Some Designations are state-related, some are national-related. So I've combined the categories that are state and the categories that are national into the value in checkboxes. I've put all Towns in a select. The Designations categories are in checkboxes and look like this:

<input type="checkbox" class="checkbox" name="category[]" value="2336|2332|2335" selected><label>National Register</label> <input type="checkbox" class="checkbox" name="category[]" value="2334|2337" selected><label>State Register</label>

and the Town categories look like this:

<select name="category[]" id="ctm_city"> <option value="">-- Select option --</option>
<option value="2158">Andover</option> <option value="2159">Ansonia</option> <option value="2160">Ashford</option> <option value="2161">Avon</option> </select>

I'd like if a Town category is selected that it is required but the designation categories can be any of the categories listed in its value. But I've only been able to get results from any of the combined categories (meaning the results match the town or match any of the Designations). Or if I use:

<input type="hidden" name="require_all[]" value="category">

then the results are only what matches everything...which is almost nothing. So being that both Towns and Designations are all categories (but 2 different category groups) how would I match selection from one Town category AND any category included in the selected Designation category checkbox?

As a test I've tried the query string: ?category=2148&2334|2337 and I get a disallowed query string error.

0

Since different parameters are always combined with AND, you can use a category group setup, with 2 different groups.

So, for example, for designations, use category:designations[], and for town, use category:town. You can omit the [] in the latter, as you're only selecting a single category there.

That will generate a query string like category:designations=2334|2337&category:town=2148.

| improve this answer | |
  • That did it. Exactly what I was looking for. Thanks! – smartpill Jul 17 '17 at 15:36

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.