I am attempting to build galleries of photos based on {photo_date}, a custom field containing the date on which each photo was taken. My list of photos looks something like this:
Photo# {photo_date}
1 11/1/14
2 11/1/14
3 11/1/14
4 11/16/14
5 11/16/14
6 11/22/14My goal is to have a loop that allows only one photo to appear from each date “group.” This photo will serve as the photo group’s cover image. So, after running the script, I will end up with this:
Group 1: Photo#1 (11/1/14)
Group 2: Photo#4 (11/16/14)
Group 3: Photo#6 (11/22/14)I am attempting to use a php variable inside of an EE loop to check to see if it matches:
<?php $clip = "0"; ?>
{exp:channel:entries channel="event_photos" dynamic="no" sort="asc" orderby="photo_date" search:photo_date="not IS_EMPTY"}
<div class="clear floatnone">
{if "{photo_event}{photo_event:url_title}{/photo_event}" == "<?php echo $currentSegment; ?>"} <!-- filter only this event's photos -->
Before add: <?php echo $clip; ?>
{if "{photo_date format='%m/%d/%y'}" != "<?php echo $clip; ?>"}
{title}
<a href="http://{photo}" title="{photo_caption}">{photo}</a>
{/if}
<?php $clip = "{photo_date format='%m/%d/%y'}"; ?>
After add: <?php echo $clip; ?>
{/if}
</div>
{/exp:channel:entries}I think this should work, but it doesn’t. It seems that the PHP variable ($clip) is getting assigned at the end of the {if} loop, but gets erased at the beginning once the loops starts over. This prevents me from checking to see if the {photo_date} in question has been used or not in the previous iteration. I’m wondering how to get the variable to retain the intended value?
I appreciate any thoughts or maybe a more elegant solution!