Forum
Counting number of repeated items
Hi. I'm using a repeater and wanted to use <perch:if> to display a different layout if there are 1, 2 or 3 repeated sections. I'm sure this must be possible, but I'm not sure how.
Any ideas? Thank you!
Hi. I'm using a repeater and wanted to use <perch:if> to display a different layout if there are 1, 2 or 3 repeated sections. I'm sure this must be possible, but I'm not sure how.
Any ideas? Thank you!
I think I've answered my own question.
I used
<perch:content id="perch_item_count" type="hidden" />
in each repeated section and then used
<perch:if id="perch_item_count" value="2">
to show the specific layout when the repeater contains 2 items. Hope this is the best way!
Hi David,
Works for me
Thanks Dexter. I actually think I'm trying to do something that may not be possible...
It is possible to call particular fields from each repeated region?
For instance, I'd like to pull image 1 from repeated region 1 and image 2 from repeated region 2...?
I'm trying to build an HTML Email builder... so clients can quickly create HTMLs with their articles. Which means I want to do something like 'If section has 2 articles then use this template'. The problem is the HTML emails layout isn't uniform – there are spacers here and there and everywhere!
You can get the item count with:
Thanks Drew. Is there anyway to get at content from a particular item within a repeater? For instance if I wanted to do something like this:
You should be able to do:
and so on. The repeater is looped, so you need to think of it in that way.
Awesomeeeeee!
Thank you so much Drew!
Is it possible to use this in a
<perch:after>
block of the repeater with<perch:if>
to output different content if there is 1 or more than one item in the repeater ?