<p>The value is stored as a serialized array in your database,  you would need to filter for the <strong>string</strong> <code>"["healthcare","food-fitness"]"</code></p>

<p>Since your query parameter is an array you just need to prepend an <code>and</code> parameter to it so it looks like </p>

<pre><code>articles_categories(['and',  '*healthcare*', '*food-fitness*'])
</code></pre>

<p>If you have only one parameter and want an exact match you need to search for the exact string</p>

<pre><code>craft.entries.articles_categories('["healthcare"]')
</code></pre>

CC BY-SA 4.0
2018-08-26T20:17:26.600Z
So, I pass it like this: {% paginate craft.entries.section('blogArticles').limit(10).search(articles_categories(['and',  '*healthcare*', '*food-fitness*'])) as pageInfo, pageEntries %} ? This doesn't work. Perhaps you can expand your answer to include my example? Also, I'm only passing one search parameter in my entry query and I want to match exact on that one parameter only.
Vaughn D. Taylor
CC BY-SA 4.0
2018-08-27T05:09:41.353Z
I added an example that will fit your needs. The search parameter is not what you want. You need to set the `articles_categories` property
Robin Schambach
CC BY-SA 4.0
2018-08-27T14:14:56.333Z
What does my answer has to do with categories and why should you need to change those? My answer is completely compatible with pagination
Robin Schambach
CC BY-SA 4.0
2018-08-27T14:31:22.097Z
You're right, so I deleted my comment. What I really want to do is give you credit for this answer, but I'm taking the code you're providing me and putting it in place, and it's still not returning. Perhaps if you expanded your answer to not just include small snippets, but instead include a full example? If another user were to see your answer, they would not be able to use it because it's very limited.
Vaughn D. Taylor
CC BY-SA 4.0
2018-08-27T14:55:29.880Z
This place is not meant for "copy & paste" code. It's for learning purpose and there is no real reason to include the entire unnecessary parameters to the query. So if someone later wants to get to know how to fetch elements based on checkbox values he/she will only see the required information.  The `paginate` function requires a parameter of type `ElementQuery` you only need to change the property of your field handle to the exact value in your DB, that's it. `{% paginate craft.entries.section('blogArticles').limit(10).articles_categories('["healthcare"]') as pageEntries %}`
Robin Schambach
CC BY-SA 4.0
2018-08-27T18:36:13.770Z
I'm not looking for copy & paste code -- just the context where your code should appear because as I mentioned (and which is true with your latest code), your recommendation does not work. I'll sort it out. I'm well aware of what Stack is for, and I don't feel like your answer is complete enough to help anyone in the future -- which is also one of the purposes of Stack.
Vaughn D. Taylor
CC BY-SA 4.0
2018-08-26T07:02:29.893Z
2018-08-27T05:08:18.260Z
2018-08-27T05:08:18.260Z
Robin Schambach
<p>It seems like this should be a simple thing, but it's evading me... I have a checkbox field in my entry named "articles_categories". Just to clarify, these are not actual categories -- they are checkboxes and I cannot modify them at this point.</p>

<p>I want to use the option value of the checkbox as an exact search parameter. I'm using pagination, so it needs to pass through paginate. This is what I have:</p>

<pre><code>{% set topic = craft.request.getQuery('topic') %}

{% paginate craft.entries.section('blogArticles').limit(10).search(topic) as pageInfo, pageEntries %}
</code></pre>

<p>The option values are being passed as the topic parameter. For example, '?topic=healthcare',  or '?topic=food-fitness'. I'm getting a different set of results from each query, however, I don't believe that this is set up to return an exact match on the value passed through the search function.</p>

<p>I need only the articles that have an exact match in that field.</p>

<search><paginate>
Search in checkbox field with pagination
# Search in checkbox field with pagination

(Asked by: username_0 on 2018-08-25)

It seems like this should be a simple thing, but it's evading me... I have a checkbox field in my entry named "articles_categories". Just to clarify, these are not actual categories -- they are checkboxes and I cannot modify them at this point.
I want to use the option value of the checkbox as an exact search parameter. I'm using pagination, so it needs to pass through paginate. This is what I have:
{% set topic = craft.request.getQuery('topic') %}

{% paginate craft.entries.section('blogArticles').limit(10).search(topic) as pageInfo, pageEntries %}

The option values are being passed as the topic parameter. For example, '?topic=healthcare',  or '?topic=food-fitness'. I'm getting a different set of results from each query, however, I don't believe that this is set up to return an exact match on the value passed through the search function.
I need only the articles that have an exact match in that field.

**Tags:** search, paginate


---

## 1 answers

### Answer by username_1 on 2018-08-26. Score: 1

The value is stored as a serialized array in your database,  you would need to filter for the string "["healthcare","food-fitness"]"
Since your query parameter is an array you just need to prepend an and parameter to it so it looks like 
articles_categories(['and',  '*healthcare*', '*food-fitness*'])

If you have only one parameter and want an exact match you need to search for the exact string
craft.entries.articles_categories('["healthcare"]')

> **Comments:**
> **username_0**: So, I pass it like this: {% paginate craft.entries.section('blogArticles').limit(10).search(articles_categories(['and',  '*healthcare*', '*food-fitness*'])) as pageInfo, pageEntries %} ? This doesn't work. Perhaps you can expand your answer to include my example? Also, I'm only passing one search parameter in my entry query and I want to match exact on that one parameter only.  
> **username_1**: I added an example that will fit your needs. The search parameter is not what you want. You need to set the `articles_categories` property  
> **username_1**: What does my answer has to do with categories and why should you need to change those? My answer is completely compatible with pagination  
> **username_0**: You're right, so I deleted my comment. What I really want to do is give you credit for this answer, but I'm taking the code you're providing me and putting it in place, and it's still not returning. Perhaps if you expanded your answer to not just include small snippets, but instead include a full example? If another user were to see your answer, they would not be able to use it because it's very limited.  
> **username_1**: This place is not meant for "copy & paste" code. It's for learning purpose and there is no real reason to include the entire unnecessary parameters to the query. So if someone later wants to get to know how to fetch elements based on checkbox values he/she will only see the required information.  The `paginate` function requires a parameter of type `ElementQuery` you only need to change the property of your field handle to the exact value in your DB, that's it. `{% paginate craft.entries.section('blogArticles').limit(10).articles_categories('["healthcare"]') as pageEntries %}`  
> **username_0**: I'm not looking for copy & paste code -- just the context where your code should appear because as I mentioned (and which is true with your latest code), your recommendation does not work. I'll sort it out. I'm well aware of what Stack is for, and I don't feel like your answer is complete enough to help anyone in the future -- which is also one of the purposes of Stack.  

---

