0

I'm using the Geofinder plugin to search for events taking place in an area.

Each Event is assigned one of five categories. The search works fine when I select a category, but I'm unsure how to get it to search all categories, leaving the value empty doesn't produce the correct results.

Here is the simple code:

<select name="categories[]" id="categories">
<option value="">Select All</option>
{exp:channel:categories channel="calendar_events" style="linear"}
<option value="{category_id}">{category_name}</option>
{/exp:channel:categories}
</select>

As I say the 'select all' doesn't work properly.

1

I haven't had experience with the Geofinder add-on before, however the following should work for anything that uses the Channel Entries API behind the scenes.

<select name="categories[]" id="categories">
    <option value="not -1">Select All</option>
    {exp:channel:categories channel="calendar_events" style="linear"}
    <option value="{category_id}">{category_name}</option>
    {/exp:channel:categories}
</select>
| improve this answer | |
0

This isn't the most efficient code, but you could do this:

<select name="categories[]" id="categories">
  <option value="{exp:channel:categories channel='calendar_events' style='linear' backspace='1'}{category_id}|{/exp:channel:categories}">Select All</option>
  {exp:channel:categories channel="calendar_events" style="linear"}
  <option value="{category_id}">{category_name}</option>
  {/exp:channel:categories}
</select>
| improve this answer | |

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.