Forum

Thread tagged as: Question, Problem

Add number to repeater

I want to create a repeater that will add a class with a number, like this;

<div class="item-1">
 <p>Some Content</p>
</div>

<div class="item-2">
 <p>Some Content</p>
</div>

so that each use of the template is identifiable by it's class.

Anyone know if/how this is possible?

Many thanks,

Ian

Ian Buchanan

Ian Buchanan 0 points

  • 5 years ago

EDITED:

<div class="item-<perch:content id="perch_item_index" type="hidden" />">
<p>Some Content</p>
</div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you probably want:

<perch:content id="perch_item_index" type="hidden" />

unless I've misunderstood. perch_item_index will give the index of the item within the repeater, and type="hidden" will stop the tag showing up as an editable field.

Drew McLellan said:

I think you probably want:

<perch:content id="perch_item_index" type="hidden" />

unless I've misunderstood. perch_item_index will give the index of the item within the repeater, and type="hidden" will stop the tag showing up as an editable field.

Ahh, yes. I did miss that. Thanks Drew. I better stop trying to help while on my iPhone as I miss too much :(

I'm going to edit my reply above.

Thanks Drew, that was exactly what I needed. Thank you for getting back to me on a Sunday, much appreciated.