photos vs nested albums

dberansky

Joined: 2002-08-16
Posts: 19
Posted: Thu, 2002-10-31 07:34

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

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Thu, 2002-10-31 07:55

<!-- 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 &amp;&amp; $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:

 
dberansky

Joined: 2002-08-16
Posts: 19
Posted: Thu, 2002-10-31 08:36

Thanks for the code, I'll give it a go.

Quote:
Also... search the forums/mailing lists... I'm sure "latest addition" code exists in some form. :smile:

One would think. :smile: That was my first reaction too, but I couldn't find anything good.