ZenphotoCMS Forum
images.hitcounter increment - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: images.hitcounter increment (/thread-1870.html)

Pages: 1 2


images.hitcounter increment - edasque - 2007-12-10

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 ?).




images.hitcounter increment - edasque - 2007-12-10

I see a function hitcounter() but nothing seems to ever call it. Reserved for future use ?




images.hitcounter increment - edasque - 2007-12-10

that seems to work, calling it in image.php. But none of the themes seem to use it.




images.hitcounter increment - edasque - 2007-12-10

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




images.hitcounter increment - sbillard - 2007-12-10

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");




images.hitcounter increment - edasque - 2007-12-10

What do you think of the SQL error I get when I use it though ?




images.hitcounter increment - sbillard - 2007-12-10

Probably because you passed the wrong value for $option




images.hitcounter increment - edasque - 2007-12-11

Hmmmm, that may be true of trunk but it's not true of the release since hitcounter takes no parameter.




images.hitcounter increment - acrylian - 2007-12-11

In zp 1.1.2 the hitcounter works only on image.php and does not have any options. (if I am not wrong).




images.hitcounter increment - edasque - 2007-12-17

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).




images.hitcounter increment - sbillard - 2007-12-17

  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.




images.hitcounter increment - edasque - 2007-12-17

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




images.hitcounter increment - acrylian - 2007-12-17

We have already functions for that:
printPopularAlbums($number)
printPopularImages($number)




images.hitcounter increment - edasque - 2007-12-17

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 ?




images.hitcounter increment - acrylian - 2007-12-17

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.




images.hitcounter increment - edasque - 2007-12-17

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




images.hitcounter increment - sbillard - 2007-12-17

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.




images.hitcounter increment - edasque - 2007-12-18

Good point, sbillard.




images.hitcounter increment - marc - 2008-01-02

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.




images.hitcounter increment - sbillard - 2008-01-02

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.