<p>There's no easy twig function available to do this, but the code from <a href="https://stackoverflow.com/questions/17715777/how-to-make-3-columns-table-with-twig-in-symfony2">this answer</a> should be able to help you.</p>

<pre><code>{% set columns = 3 %}
{% for entry in entries %}
    {% if loop.first or loop.index0 is divisibleby(columns) %}
        &lt;tr&gt;
    {% endif %}

    &lt;td&gt;{{ entry.title }}&lt;/td&gt;

    {% if loop.last and loop.index is not divisibleby(columns) %}
        {% for n in range(low=columns - (loop.index % columns), high=1, step=-1) %}
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        {% endfor %}
    {% endif %}

    {% if loop.last or loop.index is divisibleby(columns) %}
        &lt;/tr&gt;
    {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-09-10T20:09:21.853Z
That's a good start, but how can that work with different columns as `<div>`s?
Malte
CC BY-SA 3.0
2017-09-10T18:35:28.280Z
2017-09-10T18:35:28.280Z
Rias
<p>You'll need to loop through all entries first and divide the entries into three arrays. Then using a combination of <code>id</code> and <code>fixedOrder</code> you can create three more entries calls to loop through each column and it's entries.</p>

<p>This would make a nice dynamic solution that doesn't need refactoring as more entries are added.</p>

<p><a href="https://craftcms.com/docs/templating/craft.entries#fixedOrder" rel="nofollow noreferrer">https://craftcms.com/docs/templating/craft.entries#fixedOrder</a>
<a href="https://craftcms.com/docs/templating/craft.entries#id" rel="nofollow noreferrer">https://craftcms.com/docs/templating/craft.entries#id</a></p>

CC BY-SA 3.0
2017-09-11T19:30:08.513Z
Sounds great! Can you give me a boost with a small example of the syntax? I don't know how exactly to accomplish this with twig.
Malte
CC BY-SA 3.0
2017-09-11T19:15:47.290Z
2017-09-11T19:15:47.290Z
Chris Southam
<p>I'm trying to build a feed of entries in a column grid. Something like that:</p>

<pre><code>&lt;div class="column"&gt;
 &lt;a class="entry"&gt;First entry&lt;/a&gt;
 &lt;a class="entry"&gt;Fourth entry&lt;/a&gt;
&lt;/div&gt;

&lt;div class="column"&gt;
 &lt;a class="entry"&gt;Second entry&lt;/a&gt;
 &lt;a class="entry"&gt;Fifth entry&lt;/a&gt;
&lt;/div&gt;

&lt;div class="column"&gt;
 &lt;a class="entry"&gt;Third entry&lt;/a&gt;
 &lt;a class="entry"&gt;Sixth entry&lt;/a&gt;
&lt;/div&gt;
</code></pre>

<p>How do I achieve that? In my head <code>.batch(3)</code> only works horizontally for rows.</p>

<p><em>Edit:</em> To make it more clearly, that's my goal and the reason for columns instead of rows:</p>

<p><a href="https://i.sstatic.net/wmLq3.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wmLq3.jpg" alt="Column Grid"></a></p>

<entries><layout>
Split entries in columns
# Split entries in columns

(Asked by: username_0 on 2017-09-09)

I'm trying to build a feed of entries in a column grid. Something like that:

 First entry
 Fourth entry



 Second entry
 Fifth entry



 Third entry
 Sixth entry


How do I achieve that? In my head .batch(3) only works horizontally for rows.
Edit: To make it more clearly, that's my goal and the reason for columns instead of rows:

**Tags:** entries, layout


---

## 2 answers

### Answer by username_1 on 2017-09-10. Score: 1

There's no easy twig function available to do this, but the code from this answer should be able to help you.
{% set columns = 3 %}
{% for entry in entries %}
    {% if loop.first or loop.index0 is divisibleby(columns) %}
        
    {% endif %}

    {{ entry.title }}

    {% if loop.last and loop.index is not divisibleby(columns) %}
        {% for n in range(low=columns - (loop.index % columns), high=1, step=-1) %}
             
        {% endfor %}
    {% endif %}

    {% if loop.last or loop.index is divisibleby(columns) %}
        
    {% endif %}
{% endfor %}

> **Comments:**
> **username_0**: That's a good start, but how can that work with different columns as `<div>`s?  

---

### Answer by username_2 on 2017-09-11. Score: 1

You'll need to loop through all entries first and divide the entries into three arrays. Then using a combination of `id` and `fixedOrder` you can create three more entries calls to loop through each column and it's entries.

This would make a nice dynamic solution that doesn't need refactoring as more entries are added.

<https://craftcms.com/docs/templating/craft.entries#fixedOrder>
<https://craftcms.com/docs/templating/craft.entries#id>

> **Comments:**
> **username_0**: Sounds great! Can you give me a boost with a small example of the syntax? I don't know how exactly to accomplish this with twig.  

---

