Member
Member
macalter   2008-04-22, 15:56
#1

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

Administrator
Member
Member
macalter   2008-04-22, 17:49
#3

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.

Administrator
Administrator
acrylian   2008-04-22, 18:18
#4

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

Member
Member
macalter   2008-04-22, 19:49
#5

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

Administrator
Administrator
acrylian   2008-04-22, 21:01
#6

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

`

                 ">





                 ">

`
(default theme index.php)

Member
Member
macalter   2008-04-23, 18:17
#7

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.

Administrator
Administrator
acrylian   2008-04-24, 14:09
#8

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.

Administrator
Administrator
acrylian   2008-04-24, 16:03
#9

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.

Member
Member
macalter   2008-04-28, 16:37
#10

Okay, got it Dizziness affects one's memory!

Member
Member
vnvsven   2008-06-09, 11:04
#11

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

Administrator
Administrator
acrylian   2008-06-09, 11:22
#12

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)

Member
Member
vnvsven   2008-06-09, 14:14
#13

oh thanx ... I'll try it.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.