Member
Member
freindler   2007-12-29, 12:34
#1

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

Member
Member
sbillard   2007-12-29, 23:46
#2

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.

Member
Member
timo   2007-12-30, 06:03
#3

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).

Member
Member
freindler   2007-12-30, 13:55
#4

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

Member
Member
sbillard   2007-12-30, 21:22
#5

Will do, thanks for testing it out.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.