<p>I think you're getting your variable names mixed up. Something like this should work:</p>

<pre><code>{% for row in entry.content1|batch(2) %}
&lt;div class="row"&gt;
   {% for block in row %}
   &lt;div class="col-sm-6"&gt;Content&lt;/div&gt;
   {% endfor %}
&lt;/div&gt;
{% endfor %}
</code></pre>

<p>I've changed the name of the first <code>block</code> to <code>row</code>.</p>

CC BY-SA 3.0
2016-04-13T13:14:07.427Z
No worries, I've done it myself :)
Steve Holland
CC BY-SA 3.0
2016-04-13T12:52:20.640Z
2016-04-13T12:52:20.640Z
Steve Holland
<p>I tried to code an output in twig that should look the following ( 2 columns in one row), i figured that i will need the batch function</p>

<pre><code>     &lt;div class="row"&gt;
      &lt;div class="col-sm-6"&gt;Content&lt;/div&gt;
      &lt;div class="col-sm-6"&gt;Content&lt;/div&gt;
     &lt;/div&gt;    
 &lt;div class="row"&gt;
      &lt;div class="col-sm-6"&gt;Content&lt;/div&gt;
      &lt;div class="col-sm-6"&gt;Content&lt;/div&gt;
     &lt;/div&gt;
</code></pre>

<p>My attempt is : </p>

<pre><code> {% for block in entry.content1|batch(2) %}
  &lt;div class="row"&gt;
    {% for block in row %}
    &lt;div class="col-sm-6"&gt;Content&lt;/div&gt;
    {% endfor %}
  &lt;/div&gt;
 {% endfor %}
</code></pre>

<p>but it doesn't work like that, i looked it up in the twig documentation, the error from craft i get is "Variable "row" does not exist", so i tried changing it to {% for entry in block %} but that doesn't work either.</p>

<templating><layout>
Trying to achieve a row column layout with batch
# Trying to achieve a row column layout with batch

(Asked by: username_0 on 2016-04-13)

I tried to code an output in twig that should look the following ( 2 columns in one row), i figured that i will need the batch function
     
      Content
      Content
         
 
      Content
      Content
     

My attempt is : 
 {% for block in entry.content1|batch(2) %}
  
    {% for block in row %}
    Content
    {% endfor %}
  
 {% endfor %}

but it doesn't work like that, i looked it up in the twig documentation, the error from craft i get is "Variable "row" does not exist", so i tried changing it to {% for entry in block %} but that doesn't work either.

**Tags:** templating, layout


---

## 1 answers

### Answer by username_1 on 2016-04-13. Score: 5 | Accepted answer

I think you're getting your variable names mixed up. Something like this should work:
{% for row in entry.content1|batch(2) %}

   {% for block in row %}
   Content
   {% endfor %}

{% endfor %}

I've changed the name of the first block to row.

> **Comments:**
> **username_1**: No worries, I've done it myself :)  

---

