<p>Set it as a variable inside your loop and you can reuse it all you want.</p>

<pre><code> {% for entry in craft.entries.section('yourSection') %}
    {% set loopIndex = loop.index %}
    &lt;li&gt;"rs-{{loopIndex}}" id="slide-{{loopIndex}}-layer-2"&lt;/li&gt;
 {% endfor %}
</code></pre>

CC BY-SA 3.0
2016-10-02T08:59:34.490Z
2016-10-03T19:01:33.143Z
2016-10-03T19:01:33.143Z
Jan_dh
<p>I am working on a testimonial slider and each slide is wrapped in an <code>&lt;li&gt;</code> tag. The JS looks for a similar id number, one for each layer of the slide, in this case I need to change the 1 in the example below.</p>

<p>Example:</p>

<p>"rs-1"
id="slide-1-layer-2" 
id="slide-1-layer-3" </p>

<p>I loop through the entries with a normal {% for %}{% endfor %} statement and I tried rendering the required number (1) with the {{ loop.index }} but I guess you can only use this once...</p>

<p>Is there a method do this? Perhaps with Twig? </p>

<p>If I am not clear this is what the result should be:</p>

<pre><code>&lt;li&gt;"rs-1"
        id="slide-1-layer-2" 
        id="slide-1-layer-3" 
&lt;/li&gt;
&lt;li&gt;"rs-2"
        id="slide-2-layer-2" 
        id="slide-2-layer-3" 
&lt;/li&gt;
&lt;li&gt;"rs-3"
        id="slide-3-layer-2" 
        id="slide-3-layer-3" 
&lt;/li&gt;
</code></pre>

<p>etc...</p>

CC BY-SA 3.0
2016-10-05T13:14:58.403Z
Nutmeg, I think the answer below is correct or do you still have issues with something?
Jan_dh
CC BY-SA 3.0
2016-10-05T21:21:39.763Z
yes, thank you Jan! Next is to use this in a sum, but i am sure thats done with a Twig native tags
Nutmeg
<count>
How to add a unique number for each reiteration and render it multiple times?
# How to add a unique number for each reiteration and render it multiple times?

(Asked by: username_0 on 2016-10-02)

I am working on a testimonial slider and each slide is wrapped in an  tag. The JS looks for a similar id number, one for each layer of the slide, in this case I need to change the 1 in the example below.
Example:
"rs-1"
id="slide-1-layer-2" 
id="slide-1-layer-3" 
I loop through the entries with a normal {% for %}{% endfor %} statement and I tried rendering the required number (1) with the {{ loop.index }} but I guess you can only use this once...
Is there a method do this? Perhaps with Twig? 
If I am not clear this is what the result should be:
"rs-1"
        id="slide-1-layer-2" 
        id="slide-1-layer-3" 

"rs-2"
        id="slide-2-layer-2" 
        id="slide-2-layer-3" 

"rs-3"
        id="slide-3-layer-2" 
        id="slide-3-layer-3" 


etc...

**Tags:** count

> **Comments:**
> **username_1**: username_0, I think the answer below is correct or do you still have issues with something?  
> **username_0**: yes, thank you Jan! Next is to use this in a sum, but i am sure thats done with a Twig native tags  

---

## 1 answers

### Answer by username_1 on 2016-10-02. Score: 6 | Accepted answer

Set it as a variable inside your loop and you can reuse it all you want.
 {% for entry in craft.entries.section('yourSection') %}
    {% set loopIndex = loop.index %}
    "rs-{{loopIndex}}" id="slide-{{loopIndex}}-layer-2"
 {% endfor %}


---

