<p>The main problem is your URL isn't formatted correctly. You need brackets after each 'size' parameter to make an array of those values. Otherwise, it only picks up the last value.</p>

<p><code>http://domain.com/search/results?size[]=small&amp;size[]=medium</code></p>

<p>Then you can do something like this:</p>

<pre><code>{% set sizeQuery = craft.request.getParam('size') %}

{% set params = {section: 'shorts', limit: null} %}

{% if sizeQuery %}
  {% set params = params|merge({'size':sizeQuery}) %}
{% endif %}
</code></pre>

<p>Also, you can use the dump() function to test what craft.request.getParam('size') is finding in your URL.</p>

<pre><code>{{ dump(sizeQuery) }}
</code></pre>

<p>This URL: <a href="http://domain.com/search/results?size=small&amp;size=medium" rel="nofollow">http://domain.com/search/results?size=small&amp;size=medium</a></p>

<p>... returns <code>string(5) "medium"</code>.</p>

<p>But this URL: <a href="http://domain.com/search/results?size[]=small&amp;size[]=medium" rel="nofollow">http://domain.com/search/results?size[]=small&amp;size[]=medium</a></p>

<p>... returns <code>array(2) { [0]=&gt; string(5) "small" [1]=&gt; string(5) "medium" }</code>.</p>

CC BY-SA 3.0
2015-08-03T20:34:21.183Z
2015-08-03T20:34:21.183Z
Alex Roper
<p>I have entries in a channel called "shorts".
Each of those entries has a field called "size" that can be a value of small, medium or large.</p>

<p>I have created a form where I want users to be able to filter entries where the field could match small and medium (for example). I am using checkboxes on my front end form and a drop down field on the Craft admin form.</p>

<p>The URL I'm utilizing looks like this: <a href="http://domain.com/search/results?size=small&amp;size=medium" rel="nofollow">http://domain.com/search/results?size=small&amp;size=medium</a></p>

<p>But only the mediums are being displayed.</p>

<p>This is my code. I am not sure how to join the two together so smalls and mediums are displayed:</p>

<pre><code>{% set params = {section: 'shorts', limit: null}
{% if craft.request.getParam('size') %}
{% set params = params|merge({'size':size}) %}
{% endif %}
</code></pre>

<filter><queries><querystring>
Find Entries with Multiple Matches in a Single Field
# Find Entries with Multiple Matches in a Single Field

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

I have entries in a channel called "shorts".
Each of those entries has a field called "size" that can be a value of small, medium or large.
I have created a form where I want users to be able to filter entries where the field could match small and medium (for example). I am using checkboxes on my front end form and a drop down field on the Craft admin form.
The URL I'm utilizing looks like this: http://domain.com/search/results?size=small&size=medium
But only the mediums are being displayed.
This is my code. I am not sure how to join the two together so smalls and mediums are displayed:
{% set params = {section: 'shorts', limit: null}
{% if craft.request.getParam('size') %}
{% set params = params|merge({'size':size}) %}
{% endif %}

**Tags:** filter, queries, querystring

---

## 1 answers

### Answer by username_1 on 2015-08-03. Score: 3 | Accepted answer

The main problem is your URL isn't formatted correctly. You need brackets after each 'size' parameter to make an array of those values. Otherwise, it only picks up the last value.
http://domain.com/search/results?size[]=small&size[]=medium
Then you can do something like this:
{% set sizeQuery = craft.request.getParam('size') %}

{% set params = {section: 'shorts', limit: null} %}

{% if sizeQuery %}
  {% set params = params|merge({'size':sizeQuery}) %}
{% endif %}

Also, you can use the dump() function to test what craft.request.getParam('size') is finding in your URL.
{{ dump(sizeQuery) }}

This URL: http://domain.com/search/results?size=small&size=medium
... returns string(5) "medium".
But this URL: http://domain.com/search/results?size[]=small&size[]=medium
... returns array(2) { [0]=> string(5) "small" [1]=> string(5) "medium" }.


---

