Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

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 %}
    <li class="circle">
        <h3 class="registration-cost">{{ row.cost }}</h3>
        <hr/>
        <h5>Through</h5>
        <h4>{{ row.date }}</h4>
    </li>          
{% endfor %}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

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 %}  
    <hr>  
{% endif %}

Stephen

share|improve this answer
    
Thank you Stephen. Steve Abraham just suggested the same thing. I was incorrectly using .limit() before. –  Steven Grant Jul 30 at 12:38
2  
STEVE ALL THE THINGS! –  Stephen Lewis Jul 30 at 12:43
    
tis a fine name -- even with your funny spelling :) –  Steven Grant Jul 30 at 12:45
    
Had to comment, just to complete the set. –  Steve Abraham Jul 30 at 15:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.