Number of images in album

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 :)

Comments

  • 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.
  • acrylian Administrator, Developer
    Simply add `echo getNumImages()` to the `next_album()`loop.
  • 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
  • acrylian Administrator, Developer
    Wrong and more complicated than necessary...:-):

    `<?php while (next_album()): ?>



    <?php endwhile; ?>

    `
    (default theme index.php)
  • I replaced all code within <div="thumb"> and <div="albumdesc"> with the above (I closed the last <div>. 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.
  • acrylian Administrator, Developer
    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.
  • acrylian Administrator, Developer
    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.
  • Okay, got it <LOL!> Dizziness affects one's memory!
  • 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
  • acrylian Administrator, Developer
    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)
  • oh thanx ... I'll try it. :)
Sign In or Register to comment.