Gallery info in a block

odyssee
odyssee's picture

Joined: 2002-10-27
Posts: 12
Posted: Sun, 2002-10-27 18:47

Hi,
I'd like to retrieve some informations, as: total number of pictures in all galleries and total openings for all pictures.
I need to place these informations in a block.
Exemple:
291 pictures in galleries
(2356 openings)
As Gallery don't use any database, I don't know in which files I can find these informations, and also how to write the php code in the block. Can someone help me?
Thank you
Kristian

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Sun, 2002-10-27 20:35

Hi Kristian...
Provided you're writing the code within the Gallery framework (say, in the html_wrap files), you can use (within <?php ?> tags):
$totalPhotos = $albumDB->numPhotos($gallery->user);
Here, $totalPhotos will hold the total number of photos (visible to the current user) in the gallery.

What do you mean by "openings" specifically? If you mean adding up all the clicks from all the photos in the gallery, you can do the following (again, provided you're doing this within the html_wrap files):
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>$numAlbums = $albumDB->numAlbums($gallery->user);
$currAlbum = new Album();
$totalClicks = 0;
for($i=1; $i<=$numAlbums; $i++) {
$currAlbum = $albumDB->getAlbum($gallery->user, $i);
$numPhotos = $currAlbum->numPhotos(0);
for($j=1; $j<=$numPhotos; $j++) {
$totalClicks += $gallery->album->getItemClicks($j);
}
}</TD></TR></TABLE><!-- BBCode End -->
Now, $totalClicks will yield the total number of clicks (only including albums/photos which are visible to the current user). Note that this code will slow your page load a good bit.

-Beckett (beck@beckettmw.com)