<p>OKay so the solution I found is this. It was much more complicated than I wanted it to be but it works.</p>

<pre><code>{% set VARIABLE = 0 %}
{% for entry in craft.entries.section('ENTRY') %}
    {% if entry.FIELDNAME.contains('CHECKBOX OPTION') %}
        {% set VARIABLE = VARIABLE + 1 %}
        &lt;li&gt;CONTENT&lt;/li&gt;
    {% endif %}
{% endfor %}
{% if VARIABLE &lt;= 1 %}
    &lt;li&gt;CONTENT&lt;/li&gt;
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-07-15T03:34:23.193Z
2015-07-15T03:34:23.193Z
JeffTalbot
<p>I'm not entirely sure what you're trying to do, so I don't know if these suggestions will help at all.</p>

<p>If you want to check if a checkbox field only has one option checked then you can simply use</p>

<pre><code>{% if entry.FIELDNAME|length == 1 %}
    ...
{% endif %}
</code></pre>

<p>If you're trying to show it in one location if a certain checkbox is checked, and a different location if a different checkbox is checked, then try...</p>

<pre><code>{# location one (maybe header) #}
{% if entry.FIELDNAME.contains("Use Location 1") %}
    &lt;li&gt;CONTENT&lt;/li&gt;
{% endif %}

{# elsewhere, location two (maybe footer) #}
{% if entry.FIELDNAME.contains("Use Location 2") %}
    &lt;li&gt;CONTENT&lt;/li&gt;
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-07-15T05:23:41.517Z
I have pretty much that exact set up for sorting my `<li>` and it does work but that was not the issue I was struggling with this time. What I needed to do now was check how many entries had option 1 ticked in the checkbox and if that number was below 1 display another `<li>`. I did figure this out above though. Thanks for the suggstion though
JeffTalbot
CC BY-SA 3.0
2015-07-15T04:05:20.523Z
2015-07-15T04:05:20.523Z
Rick
<p>I am trying to set an <code>if</code> statment that will show a <code>li</code> if there is only one entry displaying. The issue I am having is that this entry is put into two different places via checking if it contains a checkbox.
I can only seem to managed to get it to display all the time or not at all</p>

<p>The code I have at the moment is this
    <code>{% if entry.ENTRYNAME.contains('CHECKBOX OPTION') == 0 %} &lt;li&gt;CONTENT&lt;/li&gt; {% endif %}</code></p>

<p>But that does not seem to work.
I am using the Check box contains option else where and it works fine. It's  just the value check that I cannot seem to get to work. I've also tried adding both <code>.length</code> and <code>|length</code> but neither of those seem to work. </p>

CC BY-SA 3.0
2015-07-15T03:31:38.257Z
I'm confused on a few things... what does "one entry displaying" mean? What is `ENTRYNAME` in your example?  Is that an Entries field (http://buildwithcraft.com/docs/entries-fields)?
Brad Bell
CC BY-SA 3.0
2015-07-15T03:37:32.870Z
@BradBell I made a mistake. `ENTRYNAME` Is actually `FIELDNAME` which is a checkbox field. I figured out how to solve the issue and have posted the answer bellow
JeffTalbot
<templating>
How do you set an "If" option on an entry that includes "contains"
# How do you set an "If" option on an entry that includes "contains"

(Asked by: username_0 on 2015-07-15)

I am trying to set an `if` statment that will show a `li` if there is only one entry displaying. The issue I am having is that this entry is put into two different places via checking if it contains a checkbox.
I can only seem to managed to get it to display all the time or not at all

The code I have at the moment is this
`{% if entry.ENTRYNAME.contains('CHECKBOX OPTION') == 0 %}- CONTENT
{% endif %}`

But that does not seem to work.
I am using the Check box contains option else where and it works fine. It's just the value check that I cannot seem to get to work. I've also tried adding both `.length` and `|length` but neither of those seem to work.

**Tags:** templating
> **Comments:**
> **username_1**: I'm confused on a few things... what does "one entry displaying" mean? What is `ENTRYNAME` in your example?  Is that an Entries field (http://buildwithcraft.com/docs/entries-fields)?  
> **username_0**: @BradBell I made a mistake. `ENTRYNAME` Is actually `FIELDNAME` which is a checkbox field. I figured out how to solve the issue and have posted the answer bellow  

---

## 2 answers

### Answer by username_0 on 2015-07-15. Score: 2 | Accepted answer

OKay so the solution I found is this. It was much more complicated than I wanted it to be but it works.
{% set VARIABLE = 0 %}
{% for entry in craft.entries.section('ENTRY') %}
    {% if entry.FIELDNAME.contains('CHECKBOX OPTION') %}
        {% set VARIABLE = VARIABLE + 1 %}
        CONTENT
    {% endif %}
{% endfor %}
{% if VARIABLE <= 1 %}
    CONTENT
{% endif %}


---

### Answer by username_2 on 2015-07-15. Score: 2

I'm not entirely sure what you're trying to do, so I don't know if these suggestions will help at all.
If you want to check if a checkbox field only has one option checked then you can simply use
{% if entry.FIELDNAME|length == 1 %}
    ...
{% endif %}

If you're trying to show it in one location if a certain checkbox is checked, and a different location if a different checkbox is checked, then try...
{# location one (maybe header) #}
{% if entry.FIELDNAME.contains("Use Location 1") %}
    CONTENT
{% endif %}

{# elsewhere, location two (maybe footer) #}
{% if entry.FIELDNAME.contains("Use Location 2") %}
    CONTENT
{% endif %}

> **Comments:**
> **username_0**: I have pretty much that exact set up for sorting my `<li>` and it does work but that was not the issue I was struggling with this time. What I needed to do now was check how many entries had option 1 ticked in the checkbox and if that number was below 1 display another `<li>`. I did figure this out above though. Thanks for the suggstion though  

---

