Any workaround # number of images counting ALL subalbums

The function int getNumImages( ) only provides number of images in this album (not counting its sub albums)

# Is there any work around if I want to show ALL images INCLUDING ALL sub albums?
Pls. advise. I am using latest nightly build.
Many thanks in advance.

Comments

  • acrylian Administrator, Developer
    You can write a mysql query to get all that info.
  • you can try this php code: $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber
  • It pints the total number of images in the entire gallery. What I want is the total number of images in the particular album including its subalbums.

    I think it may be a mySQL query where query could be (it counts number of images where album id equals array of all subalbumIds (function getAllSubAlbumIDs($albumfolder=''))

    OR

    just the count of albumids (Image table) where albumids equals array of all subalbumIds (function get AllSubAlbumIDs())

    I am not good with mySQL. Any help would be much appreciated.

    PS. Thanks dendraya for coming back to zenphoto after a long break. :)
  • Add a where clause to your query: `WHERE folder like "%albumname%"` (albumname needs to be the actual name of the album for which you want the coung.
  • The "Image" table has "AlbumId" as field. I am having hard time writing mySQL query with albumname as field. Pls. Help.
  • acrylian Administrator, Developer
    You need to query both the images and the albums table to get what you want. For an example of such a combined query look at the image_album_statistics-plugin around line 348 or visit the mysql doc.
  • sh123 Member
    RESOLVED # Finally looked into template functions. We do have function getTotalImagesIn($_zp_current_album) for this. It works great. Thanks.
Sign In or Register to comment.