ZenphotoCMS Forum
getNumImages subalbums - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: getNumImages subalbums (/thread-1999.html)



getNumImages subalbums - freindler - 2007-12-29

Hi all,
the function getNumImages() counts right now only the images in the album directly but not the images which are in subalbums.
Is there a way to change it?

Thx,
Freindler




getNumImages subalbums - sbillard - 2007-12-29

You would have to recursively sum all subalbum numImages.

something like this should work:
`function totalImages($album) {

global $_zp_gallery;

$sum = $album->getNumImages();

$subalbums = $album->getSubalbums(0);

while (count($subalbums) > 0) {

$albumname = array_pop($subalbums);

$album = new Album($_zp_gallery, $albumname);

$sum = $sum + totalImages($album);

}

return $sum;

}`

Caveat: I have not tried this.




getNumImages subalbums - timo - 2007-12-30

This does indeed work, although it is slightly different than the getNumImages() function. You must include the album as an argument, generally you would use totalImages($_zp_current_album) (that's how I use it for each album on my index page).




getNumImages subalbums - freindler - 2007-12-30

thanks a lot,
it works perfectly,..
right now i've included it in my "theme-functions.php" mit a different name (bsetotalImages).
I will be nice if the developing team will include it in the zp-core
thanks,
freindler




getNumImages subalbums - sbillard - 2007-12-30

Will do, thanks for testing it out.