I'm using two search fields, each searching a different category group, and creating an inclusive category search by combining those fields. The form code looks like this:
<form id="directory-search" method="post" action="/directory/search">
{exp:super_search:search}
<fieldset class="search">
<div class="center">
<h1>Directory</h1>
<a class="btn directory open-collapsed mobile-only" href="#">Search</a>
<ul class="search-row">
<li>
<label for="channel">What?</label>
<select class="replace-hfirst" name="category[]">
<option value="">- choose vendor type -</option>
{exp:channel:categories category_group="10" style="linear" show_empty="no"}
<option value="{category_url_title}&&" data-selectedtext="{category_name}" {if super_search_category_{category_url_title}}selected="selected"{/if}>{if parent_id != '0'} {/if}{category_name}</option>
{/exp:channel:categories}
</select>
</li>
<li>
<label for="category">Where?</label>
<select class="replace-hfirst" name="category[]">
<option value="">- choose location -</option>
<option value="" data-selectedtext="All Locations" {if super_search_category == ""}selected="selected"{/if}>All Locations</option>
{exp:channel:categories category_group="2" style="linear" show_empty="no"}
<option value="{category_url_title}" data-selectedtext="{category_name}" {if super_search_category_{category_url_title}}selected="selected"{/if}>{if parent_id != '0'} {/if}{category_name}</option>
{/exp:channel:categories}
</select>
</li>
<li>
<label for="keywords">Search</label>
<input type="text" class="search" name="keywords" value="{super_search_keywords}" placeholder="Optional Keyword" />
</li>
<li class="button">
<a class="btn directory submit" href="#">Search</a>
</li>
</ul>
</div><!-- end .center -->
</fieldset>
{/exp:super_search:search}
</form>
And the resulting search string could look like this: search&category=auckland+photo
"auckland" is a category in one group and "photo" is a category in the second group.
Now I need to find a way to add "selected" to the select option for each category so the searched category is highlighted.
Normally I would do something like:
{if super_search_category == "{category_url_title}"}selected="selected"{/if}
...inside the select option tag. But that doesn't work now that there are multiple categories combined in the string.
The other logical thing would be something like this:
{if super_search_category_{category_url_title}}selected="selected"{/if}
Which , according to the docs sounds like it might be the right format to work with multiple inclusive categories, but that doesn't work - probably a parsing issue trying to add in the category_url_title.
So how do I go about testing to see if an inclusive search string contains each category_url_title so I can select the right option in the select boxes?