I'm trying to build a category filter on a page that lists houses that are for sale. The idea of the filter is to make it possible to select houses which, for example, are for sale or rent, have a certain amount of rooms, a minimum/maximum price and eventually a search option to search at location, postal code or street address.
I first built one filter, which filters if a house is for sale or for rent. This filter works with two anchor buttons in a list. I now want to add the next filter, which is the amount of rooms. This filter should be a dropdown (a select tag with options in it).
I got both filters to work, but I want them to stack upon each other. So when the houses that are for sale are being shown and the user clicks on houses with 4+ rooms, it shows the houses that are for sale AND have 4+ rooms.
What I came up with so far
The filter for sale/rent houses
<ul class="button-group round">
{% for offerCategory in craft.categories.group('offerTypes').find() %}
<li>
<a class="mart-button" href="{{craft.request.url}}/?category={{ offerCategory.slug }}">{{ offerCategory.title }}</a>
</li>
{% endfor %}
</ul>
The filter for the amount of rooms
<select onChange="window.location.href=this.value">
{% for offerRooms in craft.categories.group('offerRoomTypes').find() %}
<option value="{{craft.request.url}}/?category={{ offerRooms.slug }}" name>{{ offerRooms.title }}</option>
{% endfor %}
</select>
And the rest
{% if craft.request.getParam('category') is not null %}
{% set offerCategory = craft.categories.slug(craft.request.getParam('category')) %}
{% set offerRooms = craft.categories.slug(craft.request.getParam('category')) %}
{% set offers = craft.entries({
section: 'offers',
relatedTo: [
'and',
{ targetElement: offerCategory },
{ targetElement: offerRooms }
]
}) %}
{% else %}
{% set offers = craft.entries.section('offers').find() %}
{% endif %}
The URL that's being fetched is now: .../?category=forsale and when selecting rooms .../?category=4rooms. What I want to achieve is something like .../?category=forsale,4rooms (I'm nog sure if that's the right way). If someone also can tell me directly how the search should be implemented that's welcome as well ;). Thanks in advance!