Change markup depending on category of an entry I am trying to output a news section, where I want to display the news categories as classes of the article. That works fine. But I also want to change the markup for a certain category out of the group mainly for responsive layout issues as I use Bootstrap as framework. How would I do this?

Here is my code so far:

{% for entry in craft.entries.section('news').limit(5).find() %}
{% set categories = craft.categories.relatedTo(entry) %}

    {% if category.slug == 'media' %} {# ------- I MEAN THIS LINE, slug or ID would be perfect #}

    &lt;article class="col-xs-12 col-sm-6 news {% for category in categories %}{{ category.slug }}{% endfor %}" id="{{ entry.slug }}"&gt;
        &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
        {% set info = entry.info|nl2br %}
        &lt;p class="info"&gt;{{ info|raw }}&lt;/p&gt;
        {{ entry.body }}
    &lt;/article&gt;

    {% else %}

    &lt;article class="col-xs-12 news {% for category in categories %}{{ category.slug }}{% endfor %}" id="{{ entry.slug }}"&gt;
        &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
        {% set info = entry.info|nl2br %}
        &lt;p class="info"&gt;{{ info|raw }}&lt;/p&gt;
        {{ entry.body }}
        &lt;aside class="newsimages col-xs-12 col-md-6"&gt;
            {% for image in entry.images %}
            &lt;img src="{{ image.getUrl('medium') }}" alt="{{ entry.title }}" class="col-xs-12{% if loop.first %}{% else %} col-sm-6{% endif %}" /&gt;
            {% endfor %}
        &lt;/aside&gt;
    &lt;/article&gt;

    {% endif %}
{% endfor %}
You're currently fetching an array of categories even if there's only one it, I think. You either need to loop through the array or try replacing this:

{% set categories = craft.categories.relatedTo(entry) %}


with this:

{% set category = craft.categories.relatedTo(entry).first %}


Alternatively, you could scrap the category conditional altogether and use entry types, with different entry types set up for different layouts (that's my preferred method). You could also try testing for the presence of images as well (because that seems to be the only difference in the markup):

{% if entry.images | length %}
    &lt;aside class="newsimages col-xs-12 col-md-6"&gt;
        {% for image in entry.images %}
            &lt;img src="{{ image.getUrl('medium') }}" alt="{{ entry.title }}" class="col-xs-12{% if loop.first %}{% else %} col-sm-6{% endif %}" /&gt;
        {% endfor %}
    &lt;/aside&gt;
{% endif %}


Or have I misunderstood and it's the conditional you're having problems with?