images.hitcounter increment

Hi all,

when is images.hitcounter incremented ? All entries in my images table have a NULL value for that column. Am I not doing something I should be doing in my theme ? Or is it something that's not yet used in the release (but might be in trunk ?).

Comments

  • I see a function hitcounter() but nothing seems to ever call it. Reserved for future use ?
  • that seems to work, calling it in image.php. But none of the themes seem to use it.
  • It does cause this to happen though:

    5
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/gm/gallery/zp-core/functions-db.php on line 85
  • Hitcounter is a new capability in the SVN/Nightly builds. It may still be undergoing refinements in its implementation.

    The proper use of this function is to place it in the theme when you want hitcounts. It is not there by default because it adds overhead. At present you have to put a call to hitcounter in your album.php and image.php files if you want hitcounts.

    The useage of hitcounter is:

    `hitcounter("image");` for image.php and `hitcounter("album");` for album.php. If you wish to show the hitcounter then use `echo hitcounter($option");`
  • What do you think of the SQL error I get when I use it though ?
  • Probably because you passed the wrong value for $option
  • Hmmmm, that may be true of trunk but it's not true of the release since hitcounter takes no parameter.
  • acrylian Administrator, Developer
    In zp 1.1.2 the hitcounter works only on image.php and does not have any options. (if I am not wrong).
  • Is there an API call to get the hitcounter for an image or an album then ? Preferably "in context", without having to make a separate DB query (since we already have done a few to get the EXIF data for example).
  • 1. All attribute calls are 'in context' if the object has been accessed--they are cached.

    There is an api that both increments and returns the hitcounter. None that just retrieves it. The function is `hitcounter($what)` where `$what` is `image` or `alubm`. Increments and returns the hitcounter for the currene image or ablum.

    Your theme needs to include this function if you want a page to be counted.
  • Hmmm, that doesn't work in my case since I want to display the hitcounter for a few select images (the most popular for example) without incrementing it.

    The image & album classes could use a getter for hitcounter
  • acrylian Administrator, Developer
    We have already functions for that:
    printPopularAlbums($number)
    printPopularImages($number)
  • Acrylian,

    Yes, I know of those, but I want to build a slightly different version that outputs the hitnumber for each of those images/albums. Don't you think hitcounter should have a neutral getter that doesn't also increment it, something in the image and album classes ?
  • acrylian Administrator, Developer
    Sorry, just noticed that I got you wrong. You are right, we should do that for the next version.
    Its not that big problem to modify the getImage/AlbumStatisitc functions to put out the hitcounter when printing the popular images/albums, since we already do a query we could easily expand that.
  • Yes, I could see a lot of reason why a hitcounter getter would be useful.

    One additional example, not increment the hitcounter if the admin is looking at the image:

    if admin then echo getHitCounter else hitcounter(image) endif
  • edasque: good idea to not increment for the admin. We will add it and a way to get the count without incrementing it. Howver, it will take a DB query. The count can't be presumed to be static.
  • Good point, sbillard.
  • Was this ever added to have a way to get the hit count of an album or image without incrementing it? I'd like to display the hit count of an album on the main view of all the albums, but only increment the hit count for that album if the user clicks on the album.
  • Yes, it is in the nightly builds. There is a 'viewonly' parameter to hitCounter. However, I don't think that will do what you want, the function works only on the current album. It could be extended to also have a parameter which is the id of the album/image you wish to get the hitcount of.
Sign In or Register to comment.