Hi,
I'm writing a block for displaying lastest additions to the gallery. I can't figure out a way to figure out if an album contains any photos (short of manually iterating through all items). I don't mean whether an album is empty or not. An album may not be empty and still contain to photos, only subfolders. Any recommendations?
Dmitry
Posts: 3474
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>define(INCLUDING_HIDDEN_PHOTOS, TRUE);
$containsPhoto = FALSE;
$numItems = $album->numPhotos(INCLUDING_HIDDEN_PHOTOS);
$i = 1; /* whoops! forgot this first time round */
while (!$containsPhoto && $i <= $numItems) {
if (!$album->isAlbumName($i)) {
$containsPhoto = TRUE;
}
$i++;
}</TD></TR></TABLE><!-- BBCode End -->
Assuming you're currently in album $album, $containsPhoto will be true if there's something other than just subfolders. This doesn't recurse into the subalbums... you'd have to wrap this in a function to do that.
Also... search the forums/mailing lists... I'm sure "latest addition" code exists in some form. :smile:
Posts: 19
Thanks for the code, I'll give it a go.
One would think. :smile: That was my first reaction too, but I couldn't find anything good.