1

I'm planning on having two category groups assigned to each one of my entries, with one or more categories selected from each group, for each entry.

One category group would be "type" and the other "location".

Using Super Search, would it be possible to build the search form so that each of these category groups had their own select box, and then when the form is submitted, the selected categories from each groups box would be combined into the search string like:

category=category1&&category2

Essentially what I'm saying is:or can you use a category array search with data from that array coming from multiple inputs?

1 Answer 1

1

Yes. This is documented in the SuperSearch docs.

 <select name="category[]">
  <option value="{category_name}&&">{category_name}</option>
</select>  

All selects will use name="category[]" and option values will have && at the end

5
  • Thanks. I'm aware of that part of the docs. What I'm not sure about is if the categories from the two different fields will correctly combine into the properly formatted category search string. Nov 5, 2013 at 1:14
  • The answer is yes. I've added example code in my answer which shows how.
    – Anna_MediaGirl
    Nov 5, 2013 at 2:24
  • Hmmmmm....finally got around to trying this out and there's a problem. I've done as instructed and added the && after each option value, BUT the results page replaces the "&&" with "+", which completely changes the behaviour (OR instead of AND). If I manually type in cat1&&cat2 that produces the result I'm after, but I cannot get that search string using the form. Jan 23, 2014 at 8:09
  • Since my answer was from early November, it's possible things have changed in the code or it's a bug. Check out the docs to see if there are new how-to instructions.
    – Anna_MediaGirl
    Jan 24, 2014 at 17:39
  • I found that setting inclusive_categories="yes" makes the search work the way I want it to. Even with that parameter enabled the search string indicates the the categories are an "Either" search (using a +) but it's actually performing an "AND" search (&&). So it looks like Super Search converts all "&&" entities into "+" and then relies on the parameter to decide what to do with that rather than just leaving the && as it was and removing the need for the inclusive_categories param alltogether. I don't understand why it operates that way but there must be some other good reason. ;-) Jan 25, 2014 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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