I’m currently in the process of trying to filter some channel entries by using dynamic parameters.
My current template looks like this:
<form method="post" action="" id="filter" class="filter">
<div class="row">
<select name="search:country">
<option value="IS_EMPTY|not IS_EMPTY">Choose country</option>
{exp:query sql="SELECT distinct field_id_90 FROM exp_channel_data where field_id_90 != ''"}
<option value="{field_id_90}"<?php if($this->EE->input->post('search:country') == "{field_id_90}"): ?> selected="selected"<?php endif; ?>>{field_id_90}</option>
{/exp:query}
</select>
<select name="search:language">
<option value="IS_EMPTY|not IS_EMPTY">Choose language</option>
{exp:query sql="SELECT distinct field_id_89 FROM exp_channel_data where field_id_89 != ''"}
<option value="{field_id_89}"<?php if($this->EE->input->post('search:language') == "{field_id_89}"): ?> selected="selected"<?php endif; ?>>{field_id_89}</option>
{/exp:query}
</select>
</div>
<div class="row">
<select>
<option>Choose month</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name="search:city">
<option value="IS_EMPTY|not IS_EMPTY">Choose city</option>
{exp:query sql="SELECT distinct field_id_88 FROM exp_channel_data where field_id_88 != ''"}
<option value="{field_id_88}"<?php if($this->EE->input->post('search:city') == "{field_id_88}"): ?> selected="selected"<?php endif; ?>>{field_id_88}</option>
{/exp:query}
</select>
</div>
</form>
{exp:channel:entries channel="events" show-future-entries="yes" dynamic_parameters="search:country|search:city|search:language"}
Showing my entries…
{/exp:channel:entries}Now, this issue is that it’s apparently not possible to provide an empty value nor my attempt with “IS_EMPTY|not IS_EMPTY” to show channel entries when only one filtering option is selected.
The current way it works is that we need to fill out every filter option to get any results.
Can this be done in another way?
And a bonus question - can I use the dynamic parameters to filter by a certain month?