1

In the following block of code:

<!-- TemplateBeginRepeat name="slotMiddle" -->
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<!-- TemplateEndRepeat -->

I need to use a counter in order to inject a <div></div> after every 3 components iterated.

More or less i expect something like this :

<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<div></div>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<div></div>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>
<div></div>

Is this possible to achieve ?

PS: Is it also possible to use two different counters ? If i for example need to inject something else every 2 components iterated.

Thanks in advance for your help

3

As Rahul mentions, I think you're after the TemplateRepeatIndex. Just to elaborate on how it can be used, I recommend using a TemplateBeginIf with a condition:

 <!-- TemplateBeginRepeat name="slotMiddle" -->
    <uc:SlotLoader runat="server">@@Component.ID@@</uc:SlotLoader>    
    <!-- TemplateBeginIf cond="(TemplateRepeatIndex % 3) == 0" -->
        <div></div>
    <!-- TemplateEndIf -->
 <!-- TemplateEndRepeat -->

With this option you don't need a second counter, you could use the same TemplateBeginIf statement with cond="(TemplateRepeatIndex % 2) == 0" to do something every 2 iterations.

1

If you are just looking for TemplateRepeatIndex we use it as:

<!-- TemplateBeginRepeat name="MyDummyArray" -->
      @@${TemplateRepeatIndex}@@
      //put your check here on TemplateRepeatIndex
<!-- TemplateEndRepeat -->

for more...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy