Answers.Body: <p>This is just a guess, as I've never used the 'contains' method before, but it's possible that it can't be used directly with an ElementCriteriaModel query. You might have to filter the entries after the fact.</p>
  
  <pre><code>{% set entries = craft.entries.section('news') %}
  {% for entry in entries if entry.category.contains(craft.request.getSegment(2)) %}
      {{ entry.title }}
  {% endfor %}
  </code></pre>
  
  <p>This probably defeats the purpose of using it as a psuedo-category selector however.</p>
  
  <p><strong>Update</strong> If <a href="https://craftcms.stackexchange.com/questions/1979/can-entries-be-returned-based-on-checkbox-selection">this answer</a> is any indication it also looks like you could use the <code>search</code> method. Using this method, however, may not be 100% reliable if the search index becomes outdated for whatever reason.</p>
  
  <pre><code> {% set entries = craft.entries.section('news').search('category:' ~ craft.request.getSegment(2)) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-28T12:31:29.590Z
Answers.Text: I don't need to use the 'contains' method, any method that can filter directly on the ElementCriteriaModel query would suffice. Both your solutions work, out of simplicity and short code I prefer the last one. I have read in many posts about the lack of reliability for the search index, maybe @brad-bell can clarify this; can we safely use the search method in ElementCriteriaModel queries?
Answers.UserDisplayName: Alf Vestre
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-28T18:31:08.660Z
Answers.Text: You can use search, sure. But there are many reason that a search index (`craft_searchindex` table)might become out of date/sync with the data that is in the rest of the tables it is supposed to represent. So if you need 100% accuracy, 100% of the time, then don't use it.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-28T00:42:45.067Z
Answers.LastActivityDate: 2015-01-28T08:59:19.703Z
Answers.LastEditDate: 2017-04-13T12:51:00.200Z
Answers.UserDisplayName: Douglas McDonald
Answers.Body: <p>I successfully managed to set this up with Douglas' first solution above combined with another answer also from Douglas about <a href="https://craftcms.stackexchange.com/a/6571/828">array merging</a>.</p>
  
  <p>Without this merge I had to repeat all my template code first in a 'for' loop without a request segment and then again inside a 'for' loop with a request segment.</p>
  
  <p>By adding the merge I ended up with this working solution:</p>
  
  <pre><code>{% if craft.request.getSegment(2) %}
      {% set newsAll = craft.entries.section('news') %}
      {% set news = [] %}
      {% for entry in newsAll if entry.category.contains(craft.request.getSegment(2)) %}
          {% set news = news|merge([entry]) %}
      {% endfor %}
  {% else %}
      {% set news = craft.entries.section('news') %}
  {% endif %}
  
  {% for entry in news %}
      {# My template code for all or filtered entries #}
  {% endfor %}
  </code></pre>
  
  <p>Any suggestions for further shortening this code is welcome.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-28T12:28:43.080Z
Answers.LastActivityDate: 2015-01-28T12:55:12.767Z
Answers.LastEditDate: 2017-04-13T12:51:00.200Z
Answers.UserDisplayName: Alf Vestre
Body: <p>I have succsefully managed to filter entries by matching an url segment to a Radio Buttons Field in my entries, like this:
  (here <strong>category</strong> is the field handle of my Radio Buttons field)</p>
  
  <pre><code>{% set filteredEntries = craft.entries.section('news').category(craft.request.getSegment(2)) %}
  </code></pre>
  
  <p>After having to change the Radio Buttons Field to a Checkboxes Field I tried adapting my code like this:
  (here <strong>category</strong> is the field handle of my Checkboxes Field)</p>
  
  <pre><code>{% set filteredEntries = craft.entries.section('news').category.contains(craft.request.getSegment(2)) %}
  </code></pre>
  
  <p>But it doesn't work. Any suggestions?</p>
  
Tags: <entries><filter><getsegment>
Title: Filter entries by matching an url segment to Checkboxes Field values
ThreadText: # Filter entries by matching an url segment to Checkboxes Field values
  
  (Asked by: username_0 on 2015-01-27)
  
  I have succsefully managed to filter entries by matching an url segment to a Radio Buttons Field in my entries, like this:
  (here **category** is the field handle of my Radio Buttons field)
  
  ```
  {% set filteredEntries = craft.entries.section('news').category(craft.request.getSegment(2)) %}
  
  ```
  
  After having to change the Radio Buttons Field to a Checkboxes Field I tried adapting my code like this:
  (here **category** is the field handle of my Checkboxes Field)
  
  ```
  {% set filteredEntries = craft.entries.section('news').category.contains(craft.request.getSegment(2)) %}
  
  ```
  
  But it doesn't work. Any suggestions?
  
  **Tags:** entries, filter, getsegment
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-01-28. Score: 2 | Accepted answer
  
  This is just a guess, as I've never used the 'contains' method before, but it's possible that it can't be used directly with an ElementCriteriaModel query. You might have to filter the entries after the fact.
  
  ```
  {% set entries = craft.entries.section('news') %}
  {% for entry in entries if entry.category.contains(craft.request.getSegment(2)) %}
      {{ entry.title }}
  {% endfor %}
  
  ```
  
  This probably defeats the purpose of using it as a psuedo-category selector however.
  
  **Update** If [this answer](https://craftcms.stackexchange.com/questions/1979/can-entries-be-returned-based-on-checkbox-selection) is any indication it also looks like you could use the `search` method. Using this method, however, may not be 100% reliable if the search index becomes outdated for whatever reason.
  
  ```
   {% set entries = craft.entries.section('news').search('category:' ~ craft.request.getSegment(2)) %}
  
  ```
  
  > **Comments:**
  > **username_0**: I don't need to use the 'contains' method, any method that can filter directly on the ElementCriteriaModel query would suffice. Both your solutions work, out of simplicity and short code I prefer the last one. I have read in many posts about the lack of reliability for the search index, maybe @username_2 can clarify this; can we safely use the search method in ElementCriteriaModel queries?  
  > **username_2**: You can use search, sure. But there are many reason that a search index (`craft_searchindex` table)might become out of date/sync with the data that is in the rest of the tables it is supposed to represent. So if you need 100% accuracy, 100% of the time, then don't use it.  
  
  ---
  
  ### Answer by username_0 on 2015-01-28. Score: 1
  
  I successfully managed to set this up with username_1' first solution above combined with another answer also from username_1 about [array merging](https://craftcms.stackexchange.com/a/6571/828).
  
  Without this merge I had to repeat all my template code first in a 'for' loop without a request segment and then again inside a 'for' loop with a request segment.
  
  By adding the merge I ended up with this working solution:
  
  ```
  {% if craft.request.getSegment(2) %}
      {% set newsAll = craft.entries.section('news') %}
      {% set news = [] %}
      {% for entry in newsAll if entry.category.contains(craft.request.getSegment(2)) %}
          {% set news = news|merge([entry]) %}
      {% endfor %}
  {% else %}
      {% set news = craft.entries.section('news') %}
  {% endif %}
  
  {% for entry in news %}
      {# My template code for all or filtered entries #}
  {% endfor %}
  
  ```
  
  Any suggestions for further shortening this code is welcome.
  
  
  ---
  
  