getHitCounter()

Hi,

how would one use getHitCounter() to print the counts for each album in index.php ? At this point, I am in an album loop, I think. I used to call hitcounter(getAlbumID()) or something similar.

Erik

Comments

  • `$h = getHitcounter($_zp_current_album);`
  • Hmm, that doesn't seem to work on the Default theme, line 33, as such:
    `

    ...

    <?php printAlbumDesc(); ?>

    Views: <?php getHitcounter($_zp_current_album); ?>



    ...

    `
  • That might just be because your statement creates no output. Nor does it match what I showed you. You need to print the value of the hitcounter if you want it to show up.
  • ok, sorry, you're right, typo. What about:

    ...
    <p><?php printAlbumDesc(); ?></p>
    <p>Views: <?php echo getHitcounter($_zp_current_album); ?></p>
    </div>
    ...

    because it doesn't work either.
  • acrylian Administrator, Developer
    This is probably because there is no hitcount taken. With 1.2.2 the hitcounting is enabled always by default but is only taken for not logged in users.
  • This is a site that's been going on for a long while. There is a hit count on those albums when I use the deprecated function.
  • Yes, checked again, those hitcounts are not 0:

    `SELECT folder,hitcounter FROM albums where isnull(parentid)`

    `

    folder hitcounter

    Portfolio 2003 911

    Portfolio 2002 1103

    Portfolio 2005 967

    Portfolio 2001 500

    Miscellaneous 405

    Portfolio 2006 1562

    Sports 504

    Underwater 602

    Themed 613

    Others 900

    Portfolio 2007 1683

    Techniques 457

    Portfolio 2008 2196

    `
  • Have you run the Effervescence+ theme on your site? It displays hits on albums and seems to be working correctly at least on my site.
  • Hmmm, no it doesn't display hits on the albums in index.php. What I want is to display the hits for each album in the loop of index.php, like so:

    http://www.frenchguys.com/gallery/

    Where it says:
    Viewed:: times
  • Do the hits show up on the albums page?

    The function behaves as follows:

    if you pass an album parameter it will return the hitcounter for that album.
    If you do not pass an album parameter it will determine if you are on an image, album, or other page and return the image hitcount, the album hitcount, or NULL.

    Perhaps the parameter you passed is NULL.
  • Ok, that makes sense. Would I use something similar to `<?php echo getHitcounter($_zp_current_album); ?>`in a <?php while `(next_album()): ?>`
    loop ? How does one get the current album ?
  • acrylian Administrator, Developer
    I just took a quick look at the function and it actually does not allow to display the hitcounter within the next_album loop. It checks currently automatically for the gallery page to be either "album.php" or "image.php" and if not always return NULL.
    We will need to change the function so that it behaves like the old one again.
  • Ah good, I thought I was going crazy or was really incompetent. Turns out that it's that and I might have encountered a problem (I didn't cause). I am glad. Thanks for helping out guys. You're doing a great job with ZP. Can't say enough good things about it and your support.
  • acrylian Administrator, Developer
    Should be fixed in the svn now. Btw, you can also use `echo $_zp_current_album->get("hitcounter")`to get the hitcount within the next_album loop.
Sign In or Register to comment.