getNumImages and/or sub-albums ?

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' ?

Comments

  • acrylian Administrator, Developer
    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.
  • 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 :)

  • acrylian Administrator, Developer
    Ah, sorry, forgot the count() part (that happens if you answer inbetween..;-)).
Sign In or Register to comment.