Member
Member
shiatostorm   2010-06-28, 12:27
#1
I have applied the following to be displayed beneath the thumbnails for albums on the index page:
`<?php echo "(".getNumImages()." images)"; ?>`
which does as it's expected and returns something like "(23 images)", so that's working fine. What I'm wondering is how to do something that checks to see if there's sub-albums and returns the number of those - or even total of images contained within them. currently I just get a "0 images" on the index page if any sub-albums are in next level.
Is there a php way to do something along the lines of 'if no images are present state number of sub-albums instead' ?
Administrator
Administrator
acrylian   2010-06-28, 15:54
#2
Yes, pretty basic even:
`
if(getNumImages() == 0) {
echo $_zp_current_album->getNumAlbums().' albums';
} else {
echo "(".getNumImages()." images)";
}
`
To get the number of all images of all subitems you will have to code a little more.
Member
Member
shiatostorm   2010-06-28, 23:42
#3
Hi, thanks very much for that, that's the sort of thing I was after - an if/else bit of code. I added it as required but first attempt came up an error so I scanned where the function came from on the template-functions file and I was able to adapt it further to count the subalbums:
`

if(getNumImages() == 0) {

echo count($_zp_current_album->getSubalbums()).' albums';

} else {

echo "(".getNumImages()." images)";

}

`
Works brilliantly!
If anyone else out there wants, it there you go Smile
Administrator
Administrator
acrylian   2010-06-29, 08:32
#4
Ah, sorry, forgot the count() part (that happens if you answer inbetween..;-)).
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.