<p>You can repeat a loop with another <code>for</code> loop.</p>

<p>For example, here's a loop that repeats 15 times:</p>

<pre><code>{% for i in 1..15 %}
    Loop: {{ i }}&lt;br&gt;
    {% for entry in block.homeClientQuote %}
      ...
    {% endfor %}
{% endfor %}
</code></pre>

<p>You can also use the <code>i</code> variable if you need to change the output depending on the loop number.</p>

<pre><code>{% if i &gt; 10 %}{% endif %}
</code></pre>

CC BY-SA 3.0
2017-03-02T00:37:03.720Z
Tip of the ol' ballcap to ya, Mr. Roper - that did it! Thank you!
dpayne
CC BY-SA 3.0
2017-03-01T19:55:21.450Z
2017-03-01T20:01:10.307Z
2017-03-01T20:01:10.307Z
Alex Roper
<p>So I've got a Matrix block that is pulling in some entries and I'm looping through the entries in that block in a template. I'm then pulling a text field from each entry and putting it onto a page. Currently, there are three total entries in that block (though that will likely expand over time). Once I hit the third and final entry, I would like the loop to start over again at the first, loop through the entries again until it gets to the last entry and start over again. I'd like to do that continuously up to a point - say 15 loops. </p>

<p>I'm struggling with how to get the entry loop to start over once it reaches the last entry. </p>

<p>This is the current basic code that loops through the entries and then loops through the matrix blocks within the entries to output the text to pull into the page.</p>

<pre><code>{% for entry in block.homeClientQuote %}                                
    &lt;div&gt;
        {% for block in entry.clientQuote %}
            {{ block.actualClientQuote }}
        {% endfor %} 
    &lt;/div&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-03-01T07:59:20.147Z
Could you be a little more clear in your question? A thing that might clear things up for yourself is by not mixing block's and entry's as prefixes in your code inside of loops that already use these. It might be confusing and making errors hard to see if you keep using the same name's
Justin Dekkers
CC BY-SA 3.0
2017-03-01T16:18:22.007Z
@JustinDekkers Updated the question to make it more clear and good point on the mixing blocks and entries as prefixes.
dpayne
<templating><matrix><forloop><loop>
How Do I Restart an Entries Loop Once It Hits the Last Entry
# How Do I Restart an Entries Loop Once It Hits the Last Entry

(Asked by: username_0 on 2017-03-01)

So I've got a Matrix block that is pulling in some entries and I'm looping through the entries in that block in a template. I'm then pulling a text field from each entry and putting it onto a page. Currently, there are three total entries in that block (though that will likely expand over time). Once I hit the third and final entry, I would like the loop to start over again at the first, loop through the entries again until it gets to the last entry and start over again. I'd like to do that continuously up to a point - say 15 loops. 
I'm struggling with how to get the entry loop to start over once it reaches the last entry. 
This is the current basic code that loops through the entries and then loops through the matrix blocks within the entries to output the text to pull into the page.
{% for entry in block.homeClientQuote %}                                
    
        {% for block in entry.clientQuote %}
            {{ block.actualClientQuote }}
        {% endfor %} 
    
{% endfor %}

**Tags:** templating, matrix, forloop, loop
> **Comments:**
> **username_1**: Could you be a little more clear in your question? A thing that might clear things up for yourself is by not mixing block's and entry's as prefixes in your code inside of loops that already use these. It might be confusing and making errors hard to see if you keep using the same name's  
> **username_0**: @JustinDekkers Updated the question to make it more clear and good point on the mixing blocks and entries as prefixes.  

---

## 1 answers

### Answer by username_2 on 2017-03-01. Score: 2 | Accepted answer

You can repeat a loop with another for loop.
For example, here's a loop that repeats 15 times:
{% for i in 1..15 %}
    Loop: {{ i }}
    {% for entry in block.homeClientQuote %}
      ...
    {% endfor %}
{% endfor %}

You can also use the i variable if you need to change the output depending on the loop number.
{% if i > 10 %}{% endif %}

> **Comments:**
> **username_0**: Tip of the ol' ballcap to ya, Mr. Roper - that did it! Thank you!  

---

