ZenphotoCMS Forum
Number of images in album - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Number of images in album (/thread-2724.html)



Number of images in album - macalter - 2008-04-22

The slideshow gives the number of images in an album. I'd like to display the total on the gallery page of each album. (If it's a "do-it-yourself", I'd need exact copy as I don't know PHP




Number of images in album - acrylian - 2008-04-22

http://www.zenphoto.org/documentation/zenphoto/_template-functions.php.html#functiongetNumImages




Number of images in album - macalter - 2008-04-22

I'm looking at the info in the link you give and at the code of template-functions.php. I see:
/**

  • Returns the number of images in the album.
  • @return int
    */
    function getNumImages() {
    global $_zp_current_album, $_zp_current_search;
    if (in_context(ZP_SEARCH)) {
    return $_zp_current_search->getNumImages();
    } else {
    if ($_zp_current_album->isDynamic()) {
    $search = $_zp_current_album->getSearchEngine();
    return $search->getNumImages();
    } else {
    return $_zp_current_album->getNumImages();
    }
    }
    }
    /**
  • Returns the count of all the images in the album and any subalbums
  • @param object $album The album whose image count you want
  • @return int
  • @since 1.1.4
    */

function getTotalImagesIn($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 + getTotalImagesIn($album);
}
return $sum;
}
====== NOT ALL THE SLASHES AND STARS COPY OVER FROM THE ACTUAL CODE!!!!!========

in the file but don't see either showing on the Gallery pages for each album.




Number of images in album - acrylian - 2008-04-22

Simply add echo getNumImages() to the next_album()loop.




Number of images in album - macalter - 2008-04-22

Added the code to template-functions.php, wasn't sure if there was specific spot so put here:

            $_zp_albums = $search->getAlbums($all ? 0 : $_zp_page);

/ RBC 22-Apr-2008 added to show number of images /
echo getNumImages();
} else {
$_zp_albums = $_zp_current_album->getSubAlbums($all ? 0 : $_zp_page, $sorttype);

        }
    } else {

no number is appearing on the Gallery pages




Number of images in album - acrylian - 2008-04-22

Wrong and more complicated than necessary...:-):

`

                 ">





                 ">

`
(default theme index.php)




Number of images in album - macalter - 2008-04-23

I replaced all code within and with the above (I closed the last . Added the code to index.php in my DEFAULT theme. Looked at the Gallery page and the Thumbnail page of the album and no display of how many images in album.

Removed code from template-functions.php as previously understood it went.




Number of images in album - acrylian - 2008-04-24

Sorry, I don't understand what is so difficult to add getNumImages() within the next_album() loop on index.php or album.php. My example above was more than clear and exactly from index.php....
You don't have to replace any code, just add getNumImages like shown above.




Number of images in album - acrylian - 2008-04-24

Refering to your question in the other number post. All the code you posted above has nothing to do with it. Please refer to the code I posted. Find that on index.php and album.php and add the function. That's all, really nothing complicated.




Number of images in album - macalter - 2008-04-28

Okay, got it Dizziness affects one's memory!




Number of images in album - vnvsven - 2008-06-09

Ok - that works nice & easy, but how can I display the amount of images in the album plus all the subalbum. I didn't find a solution in the documentary.

thanx a lot,
Sven




Number of images in album - acrylian - 2008-06-09

Sorry, there is no function for that. You would have to write one yourself, I would suggest to use a db query for that (take the folder name as a guide for example)




Number of images in album - vnvsven - 2008-06-09

oh thanx ... I'll try it.