<p>Your <code>if</code> statements looks correct. You might check that you are testing the value vs. the name (i.e. 'Portrait' vs 'portrait') or printing out the value (using <code>{{ entry.postAspectRatio }}</code>) so you can see the output. Also, a 'dryer' way to write this might be:</p>

<pre><code>{% block content %}

    {% for entry in craft.entries.section('projects').order('postDate asc').limit(500).find() %}

        &lt;div class="title {{ entry.postAspectRatio|lower }}"&gt;
            &lt;a href="{{ entry.url }}"&gt;
                &lt;p&gt;&lt;span&gt;{{ entry.studio }}&lt;/span&gt;{{ entry.title }}&lt;/p&gt;
            &lt;/a&gt;
        &lt;/div&gt;

    {% endfor %}

{% endblock %}
</code></pre>

CC BY-SA 3.0
2014-12-15T00:19:52.973Z
2014-12-15T00:19:52.973Z
Douglas McDonald
<p>I'm showing entries on a page. Depending on the value of the field <code>postAspectRatio</code>, I would like the layout of this shown entry to change just slightly and thus requiring it's own unique markup. </p>

<p>I've tried to do this using what I know about twig IF syntax but it's not working. </p>

<p>Any help?</p>

<pre><code>{% block content %}

{% for entry in craft.entries.section('projects').order('postDate asc').limit(500).find() %}

        {% if entry.postAspectRatio == 'Portrait' %}

        &lt;div class="title portrait"&gt;
            &lt;a href="{{ entry.url }}"&gt;
                &lt;p&gt;&lt;span&gt;{{ entry.studio }}&lt;/span&gt;{{ entry.title }}&lt;/p&gt;
            &lt;/a&gt;
        &lt;/div&gt;

        {% endif %}

        {% if entry.postAspectRatio == 'Landscape' %}

        &lt;div class="title landscape"&gt;
            &lt;a href="{{ entry.url }}"&gt;
                &lt;p&gt;&lt;span&gt;{{ entry.studio }}&lt;/span&gt;{{ entry.title }}&lt;/p&gt;
            &lt;/a&gt;
        &lt;/div&gt;

        {% endif %}

{% endfor %}

{% endblock %}
</code></pre>

CC BY-SA 3.0
2014-12-13T07:59:10.147Z
Your syntax is right. What type of field is `postAspectRatio`?
carlcs
CC BY-SA 3.0
2014-12-13T08:04:12.557Z
Test the output with `{{ entry.postAspectRatio }}`.
carlcs
<templating><entries>
How to show entries with IF statement based on field
# How to show entries with IF statement based on field

(Asked by: username_0 on 2014-12-13)

I'm showing entries on a page. Depending on the value of the field postAspectRatio, I would like the layout of this shown entry to change just slightly and thus requiring it's own unique markup. 
I've tried to do this using what I know about twig IF syntax but it's not working. 
Any help?
{% block content %}

{% for entry in craft.entries.section('projects').order('postDate asc').limit(500).find() %}

        {% if entry.postAspectRatio == 'Portrait' %}

        
            
                {{ entry.studio }}{{ entry.title }}
            
        

        {% endif %}

        {% if entry.postAspectRatio == 'Landscape' %}

        
            
                {{ entry.studio }}{{ entry.title }}
            
        

        {% endif %}

{% endfor %}

{% endblock %}

**Tags:** templating, entries
> **Comments:**
> **username_1**: Your syntax is right. What type of field is `postAspectRatio`?  
> **username_1**: Test the output with `{{ entry.postAspectRatio }}`.  

---

## 1 answers

### Answer by username_2 on 2014-12-15. Score: 1

Your if statements looks correct. You might check that you are testing the value vs. the name (i.e. 'Portrait' vs 'portrait') or printing out the value (using {{ entry.postAspectRatio }}) so you can see the output. Also, a 'dryer' way to write this might be:
{% block content %}

    {% for entry in craft.entries.section('projects').order('postDate asc').limit(500).find() %}

        
            
                {{ entry.studio }}{{ entry.title }}
            
        

    {% endfor %}

{% endblock %}


---

