Member
Member
LondonLight.org   2014-04-16, 18:20
#1
Hey!

I display all images in an album in their default size on one page using a next_image loop, and I would like to also get a count of the total number of images. I'm a beginner with PHP and this is what I came up with:
`<?php $imgcount = 0; while (next_image()): $imgcount += 1; endwhile; print ($imgcount); ?>`
It works, but do I really need to iterate over the loop to get it?

I saw a function `getTotalImagesIn` exists, but can't figure out how to use it. I tried `print (getTotalImagesIn( getAlbumTitle( )));` but that fails with `Fatal error: Call to a member function getNumImages() on a non-object in /var/www/localhost/htdocs/zp/zp-core/template-functions.php on line 1985`
Administrator
Administrator
fretzl   2014-04-16, 19:08
#2
Use something like this:
`<?php echo getTotalImagesIn($_zp_current_album); ?>`
Administrator
Administrator
acrylian   2014-04-16, 19:09
#3
`print (getTotalImagesIn( getAlbumTitle( )))`
You really should look at the documentation before trying random things… That function requires an album object.
http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetTotalImagesIn
That album object is available in the global `$_zp_current_album` if you are in album context. http://www.zenphoto.org/news/zenphotos-object-model-framework

Edit: Ah, Fretzl was faster and shorter :-)
Member
Member
LondonLight.org   2014-04-17, 07:53
#4
Thank you.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.