<p>Passing the category as a comma delineated string and using <code>craft.request.getParam('category')</code> the second time will not grab the second variable <code>4rooms</code>.  First you need to parse that string into an array. This will create an array <code>['forsale','4rooms']</code>. Use the parts of that array to assign to your other variables.</p>

<pre><code>{% set params = craft.request.getParam('category')|split(',') %}
{% set offerCategory = craft.categories.slug(params[0]) %}
{% set offerRooms = craft.categories.slug(params[1]) %}
</code></pre>

CC BY-SA 3.0
2015-10-27T07:27:32.030Z
Hey aran, thanks for taking time for this. At the time I decided to filter them with jQuery instead, since I won't be getting a lot of entries. I will mark your answer as correct because I think it would as you say.
sanderfish
CC BY-SA 3.0
2015-10-27T03:33:39.663Z
2015-10-27T03:40:58.947Z
2015-10-27T03:40:58.947Z
a-am
<p>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. </p>

<p>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).</p>

<p>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. </p>

<p>What I came up with so far</p>

<p>The filter for sale/rent houses</p>

<pre><code>&lt;ul class="button-group round"&gt;
 {% for offerCategory in craft.categories.group('offerTypes').find() %}
  &lt;li&gt;
   &lt;a class="mart-button" href="{{craft.request.url}}/?category={{ offerCategory.slug }}"&gt;{{ offerCategory.title }}&lt;/a&gt;
  &lt;/li&gt;
 {% endfor %}
&lt;/ul&gt;
</code></pre>

<p>The filter for the amount of rooms</p>

<pre><code>&lt;select onChange="window.location.href=this.value"&gt;
 {% for offerRooms in craft.categories.group('offerRoomTypes').find() %}
  &lt;option value="{{craft.request.url}}/?category={{ offerRooms.slug }}" name&gt;{{ offerRooms.title }}&lt;/option&gt;
 {% endfor %}
&lt;/select&gt;
</code></pre>

<p>And the rest</p>

<pre><code>{% 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 %}
</code></pre>

<p>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!</p>

<entries><categories><filter><forloop>
Filtering entries by multiple categories with multiple filters
# Filtering entries by multiple categories with multiple filters

(Asked by: username_0 on 2015-08-27)

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

 {% for offerCategory in craft.categories.group('offerTypes').find() %}
  
   {{ offerCategory.title }}
  
 {% endfor %}


The filter for the amount of rooms

 {% for offerRooms in craft.categories.group('offerRoomTypes').find() %}
  {{ offerRooms.title }}
 {% endfor %}


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!

**Tags:** entries, categories, filter, forloop

---

## 1 answers

### Answer by username_1 on 2015-10-27. Score: 3 | Accepted answer

Passing the category as a comma delineated string and using craft.request.getParam('category') the second time will not grab the second variable 4rooms.  First you need to parse that string into an array. This will create an array ['forsale','4rooms']. Use the parts of that array to assign to your other variables.
{% set params = craft.request.getParam('category')|split(',') %}
{% set offerCategory = craft.categories.slug(params[0]) %}
{% set offerRooms = craft.categories.slug(params[1]) %}

> **Comments:**
> **username_0**: Hey aran, thanks for taking time for this. At the time I decided to filter them with jQuery instead, since I won't be getting a lot of entries. I will mark your answer as correct because I think it would as you say.  

---

