<p>I'm not sure how dynamic you need this to be. One way would be to set an order of classes to loop through with <a href="https://twig.symfony.com/doc/2.x/functions/cycle.html" rel="nofollow noreferrer">Tiwg's Cycle function</a>. This would go through each class in the array, in a cycle.</p>

<pre><code>{% set classes = ['full-wide', 'third-wide', 'third-wide', 'third-wide', 'half-wide', 'half-wide'] %}

{% for entry in entries %}
    &lt;div class="{{ cycle(classes, loop.index0) }}"&gt;
        {# output entry #}
    &lt;/div&gt;
{% endfor %}
</code></pre>

<p>If you need a bit more flexibility you could use conditionals querying the <a href="https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable" rel="nofollow noreferrer">loop variable</a> to determine where you are in the output.</p>

CC BY-SA 4.0
2019-04-07T16:50:24.073Z
Thank you, I know about cycles, but in my case loops have very different div structure and adding just one class to div is not enough
Artur Potosyan
CC BY-SA 4.0
2019-04-07T16:56:20.680Z
Ok, if you add more specifics to your question I might be able to help. What the HTML need to look like, how variable is the entry data etc. I’m also not sure what you mean by “build categories”.
Simon Kuran
CC BY-SA 4.0
2019-04-07T20:42:30.613Z
BTW, I solved my issue thanks to twig slice option
Artur Potosyan
CC BY-SA 4.0
2019-04-07T20:54:54.777Z
@ArturPotosyan post it as answer, that way others can use it. :)
Simon Kuran
CC BY-SA 4.0
2019-04-08T11:37:33.230Z
https://twig.symfony.com/doc/2.x/filters/slice.html
Artur Potosyan
CC BY-SA 4.0
2019-04-06T23:15:09.793Z
2019-04-06T23:15:09.793Z
Simon Kuran
<p>Is it possible to build categories with a list of entries that have different styling, like</p>

<pre><code>{% for entry in entries %}
    Row 1 - Entry 1 - full-wide
    Row 2 - 3 entries with (1/3 width of each)
    Row 3 - 2 entries (1/3 and 2/3 width)
    ....
{% endfor %}
</code></pre>

<p>Thank you</p>

<templating><entries>
Entries with different styling
# Entries with different styling

(Asked by: username_0 on 2019-04-06)

Is it possible to build categories with a list of entries that have different styling, like
{% for entry in entries %}
    Row 1 - Entry 1 - full-wide
    Row 2 - 3 entries with (1/3 width of each)
    Row 3 - 2 entries (1/3 and 2/3 width)
    ....
{% endfor %}

Thank you

**Tags:** templating, entries

---

## 1 answers

### Answer by username_1 on 2019-04-06. Score: 1

I'm not sure how dynamic you need this to be. One way would be to set an order of classes to loop through with Tiwg's Cycle function. This would go through each class in the array, in a cycle.
{% set classes = ['full-wide', 'third-wide', 'third-wide', 'third-wide', 'half-wide', 'half-wide'] %}

{% for entry in entries %}
    
        {# output entry #}
    
{% endfor %}

If you need a bit more flexibility you could use conditionals querying the loop variable to determine where you are in the output.

> **Comments:**
> **username_0**: Thank you, I know about cycles, but in my case loops have very different div structure and adding just one class to div is not enough  
> **username_1**: Ok, if you add more specifics to your question I might be able to help. What the HTML need to look like, how variable is the entry data etc. I’m also not sure what you mean by “build categories”.  
> **username_0**: BTW, I solved my issue thanks to twig slice option  
> **username_1**: @ArturPotosyan post it as answer, that way others can use it. :)  
> **username_0**: https://twig.symfony.com/doc/2.x/filters/slice.html  

---

