I want to find a way to create a counter that I can control the incrementing of. For example in generic programming, if I have an unknown array, and I want the first 5 items, it would look something like:
var i = 0;
foreach(var item in ItemArray){
if (something == "valueA" && i<=5) {
do something;
i++}
}
In Tridion it would look something like
<!-- TemplateBeginRepeat name="items" -->
<!-- TemplateBeginIf cond="(something == 'valueA') && (TemplateRepeatIndex <= 5)" -->
Do something
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->
The problem is obviously that TemplateRepeatIndex increments each time, and I don't want it to. I'd like something like this:
Somehow define customCounter
<!-- TemplateBeginRepeat name="items" -->
<!-- TemplateBeginIf cond="(something == 'valueA') && (customCounter <= 5)" -->
Do something
customCounter++;
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->
I'm hoping there is something out of the box that I don't know about.