Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-13T13:14:07.427Z
Answers.Text: No worries, I've done it myself :)
Answers.UserDisplayName: Steve Holland
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-13T12:52:20.640Z
Answers.LastActivityDate: 2016-04-13T12:52:20.640Z
Answers.UserDisplayName: Steve Holland
Body: <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>
  
Tags: <templating><layout>
Title: Trying to achieve a row column layout with batch
ThreadText: # 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
  
  ```
       <div class="row">
        <div class="col-sm-6">Content</div>
        <div class="col-sm-6">Content</div>
       </div>    
   <div class="row">
        <div class="col-sm-6">Content</div>
        <div class="col-sm-6">Content</div>
       </div>
  
  ```
  
  My attempt is :
  
  ```
   {% for block in entry.content1|batch(2) %}
    <div class="row">
      {% for block in row %}
      <div class="col-sm-6">Content</div>
      {% endfor %}
    </div>
   {% 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) %}
  <div class="row">
     {% for block in row %}
     <div class="col-sm-6">Content</div>
     {% endfor %}
  </div>
  {% endfor %}
  
  ```
  
  I've changed the name of the first `block` to `row`.
  
  > **Comments:**
  > **username_1**: No worries, I've done it myself :)  
  
  ---
  
  