<p>According to <a href="http://buildwithcraft.com/docs/table-fields">the Craft docs</a> , the table field returns an array of rows.</p>

<p>Assuming that is the case, you should be able to use <a href="http://twig.sensiolabs.org/doc/filters/slice.html">the Twig <code>slice</code> filter</a>:</p>

<pre><code>{% for row in registration.registrationCost | slice(0, 3) %}
</code></pre>

<p>You can then use a simple conditional to output the row divider:</p>

<pre><code>{% if loop.index == 3 %}  
    &lt;hr&gt;  
{% endif %}
</code></pre>

<p>Stephen</p>

CC BY-SA 3.0
2014-07-30T12:38:14.333Z
Thank you Stephen. Steve Abraham just suggested the same thing. I was incorrectly using .limit() before.
Steven Grant
CC BY-SA 3.0
2014-07-30T12:43:15.730Z
STEVE ALL THE THINGS!
Stephen Lewis
CC BY-SA 3.0
2014-07-30T12:45:02.000Z
tis a fine name -- even with your funny spelling :)
Steven Grant
CC BY-SA 3.0
2014-07-30T15:05:40.393Z
Had to comment, just to complete the set.
Steve Abraham
CC BY-SA 3.0
2014-07-30T12:10:00.160Z
2014-07-30T15:26:18.773Z
2014-07-30T15:26:18.773Z
Stephen Lewis
<p>I want to limit the rows returned here to 4, then if loop.index is 3 display a separator and then output the last row.</p>

<p>Does the table field have that kind of control?</p>

<pre><code>{% for row in registration.registrationCost %}
    &lt;li class="circle"&gt;
        &lt;h3 class="registration-cost"&gt;{{ row.cost }}&lt;/h3&gt;
        &lt;hr/&gt;
        &lt;h5&gt;Through&lt;/h5&gt;
        &lt;h4&gt;{{ row.date }}&lt;/h4&gt;
    &lt;/li&gt;          
{% endfor %}
</code></pre>

<templating><field><globals>
How can I limit the rows returned in a table field?
# How can I limit the rows returned in a table field?

(Asked by: username_0 on 2014-07-30)

I want to limit the rows returned here to 4, then if loop.index is 3 display a separator and then output the last row.
Does the table field have that kind of control?
{% for row in registration.registrationCost %}
    
        {{ row.cost }}
        
        Through
        {{ row.date }}
              
{% endfor %}

**Tags:** templating, field, globals

---

## 1 answers

### Answer by username_1 on 2014-07-30. Score: 7 | Accepted answer

According to the Craft docs , the table field returns an array of rows.
Assuming that is the case, you should be able to use the Twig slice filter:
{% for row in registration.registrationCost | slice(0, 3) %}

You can then use a simple conditional to output the row divider:
{% if loop.index == 3 %}  
      
{% endif %}

Stephen

> **Comments:**
> **username_0**: Thank you Stephen. Steve Abraham just suggested the same thing. I was incorrectly using .limit() before.  
> **username_1**: STEVE ALL THE THINGS!  
> **username_0**: tis a fine name -- even with your funny spelling :)  
> **username_2**: Had to comment, just to complete the set.  

---

