Pages (2): 1 2   
Member
Member
edasque   2007-12-10, 19:44
#1

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

Member
Member
edasque   2007-12-10, 20:10
#2

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

Member
Member
edasque   2007-12-10, 20:21
#3

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

Member
Member
edasque   2007-12-10, 20:32
#4

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

Member
Member
sbillard   2007-12-10, 20:48
#5

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

Member
Member
edasque   2007-12-10, 21:45
#6

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

Member
Member
sbillard   2007-12-10, 22:40
#7

Probably because you passed the wrong value for $option

Member
Member
edasque   2007-12-11, 15:51
#8

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

Administrator
Administrator
acrylian   2007-12-11, 17:57
#9

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

Member
Member
edasque   2007-12-17, 17:19
#10

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

Member
Member
sbillard   2007-12-17, 17:45
#11
  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.

Member
Member
edasque   2007-12-17, 19:11
#12

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

Administrator
Administrator
acrylian   2007-12-17, 20:17
#13

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

Member
Member
edasque   2007-12-17, 20:19
#14

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 ?

Administrator
Administrator
acrylian   2007-12-17, 20:25
#15

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.

Member
Member
edasque   2007-12-17, 20:59
#16

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

Member
Member
sbillard   2007-12-17, 21:24
#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.

Member
Member
edasque   2007-12-18, 03:11
#18

Good point, sbillard.

Member
Member
marc   2008-01-02, 06:04
#19

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.

Member
Member
sbillard   2008-01-02, 06:17
#20

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.

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.