Forum
content_custom: pulling first image from repeater
I would like to just pull the first image from the array of images found in a repeater. I thought that using perch_content_custom may allow this to happen with the "count" option, but I appear to get all the images in the array.
This is the call using a custom template:
<?php
perch_content_custom('Showhome', array(
'template' => '_showhome_thumb.html',
'count' => 1
));
?>
and the template looks like this:
<perch:repeater id="images">
<perch:if exists="image">
<img src="<perch:content id="image" bucket="showhome" />" alt="Showhome" />
<perch:else />
<img src="/img/photo-showhome-small.jpg" alt="showhome" />
</perch:if>
</perch:repeater>
I am using Perch 2.5.4.
I must be missing something, can anyone shed some light on this for me?
The count is for the items, not the repeater.
You could add a test for
perch_item_first
in the repeaterThat's great Drew - thanks for letting me know about that! That works great, but it triggers the content of the else statement when I use it. Removing the else statement solves the problem, but also gets rid of the fallback.
What does your template look like?