Total image views per album (incl. subalbums)

Hi,

I want to see on my index.php the total images views per album including subalbums. I've done it at the moment this way:

in my image.php I have:

<?php echo hitcounter('image', false); ?>
<?php hitcounter('album', false); ?>

So everytime the image is viewed it adds 1 to the image hitcounter and 1 to the albums hitcounter.

Therefore with <?php echo hitcounter('album',true,getAlbumID()); ?> on index.php I get the total views of that album.

The only problem with this workaround is, it doesn't work anymore if I work with subalbums. Is there a code that gives the total image views per album including subalbums?

Like <?php echo getTotalImagesIn($_zp_current_album);?> does it for the total number of images.

I hope you understand my problem (well its not huge a problem though, I still enjoy my zenphoto very much),

cheers,
Jeroen

Comments

  • a feature i would like to see
  • Certainly something you could add if you want.
  • and how can it be done? or is it already in zenphoto?
  • acrylian Administrator, Developer
    No, it isn't you would have to write a function yourself.
  • time for me to learn some php

    or i can use Idrownpuppies way. only its not working for subalbums
  • acrylian Administrator, Developer
    you can pass a the id of an album or image directly to the hitcounter() function to get it for a specific album/image. If you know the ids of them all you can summarize them. There is of course a way to do that more convenient via the classes. Another way would be to use a db query to get them. But I currently don't have the time to try that.
  • To display the total number of views of all images in the gallery

    <?php
    $sum = mysql_query("SELECT SUM(hitcounter) FROM zp_images");
    $views = mysql_fetch_array($sum);
    $total = $views[0];
    echo $total;
    ?>
  • acrylian Administrator, Developer
    Or use the object model so unpublished and protected items and those from protected and unpublished albums are not counted.
Sign In or Register to comment.