Member
Member
gregb34   2008-05-17, 14:22
#1

Hi,

I have a problem with the "Hit counter". In the admin panel, hit counter for all albums and images stay at 0. Any idea of this problems ?

Thanks

Administrator
Administrator
acrylian   2008-05-17, 15:38
#2

You have to add the hitcounter function to your theme files to use it. Please take a look at our functions guide.

Member
Member
gregb34   2008-05-17, 15:59
#3

It's what i have did but not on the theme used by my gallerie

Thanks !

Member
Member
altaphista   2008-05-26, 08:08
#4

I have the same problem in the Default theme, if I add `` in the code, or if I echo the value, it always stays at 0/zero. Any ideas?

Administrator
Administrator
acrylian   2008-05-26, 08:21
#5

From our documentation:
[i]Increments (optionally) and returns the hitcounter Does not increment the hitcounter if the viewer is logged in as the gallery admin[/i]
http://www.zenphoto.org/documentation-official/zenphoto/_template-functions.php.html#functionhitcounter

Member
Member
altaphista   2008-05-26, 08:33
#6

ah of course, thanx acrylian! I read over the passage "[i][b]Does not increment the hitcounter if the viewer is logged in as the gallery admin[/b][/i]"

Member
Member
plutusad   2008-11-27, 18:13
#7

i'm sorry...can i get some slightly more detailed instructions on how to get the counters working? because i am completely lost. what do it mean that "add the hitcounter function to your theme files to use it"? Add what to where? and does the counter only keep track of hits on images? or also hits on albums? can i get hits for pages too? thanks a lot in advance and sorry for my ignorance.

Administrator
Administrator
acrylian   2008-11-27, 18:28
#8

As written on the functions guide (sorry link above is outdated):
[i]Increments (optionally) and returns the hitcounter if a page is viewed (image.php and album.php only).[/i]

Your theme files in this case are image.php and/or album.php then. If you are not familiar with Zenphoto themes at all please visit the theming tutorial on our user guide:
http://www.zenphoto.org/2008/05/theming-tutorial/

If you have difficulties to read the functions guide:
http://www.zenphoto.org/2008/04/how-to-read-the-zenphoto-functions-guide/

Note that the hitcounter will be enabled by default with the coming 1.2.2 version.

If you use the Zenpage CMS plugin that has currently a separate hitcount function:
http://zenpage-functions.maltem.de/zenpage/_zenpage-template-functions.php.html#functionzenpageHitcounter

Member
Member
plutusad   2008-11-27, 18:38
#9

hmmm...i am still not getting it right. this is what i have in my template-functions.php

/
function hitcounter($option='image', $viewonly=false, $id=NULL) {
switch($option) {
case "image":
if (is_null($id)) {
$id = getImageID();
}
$dbtable = prefix('images');
$doUpdate = true;
break;
case "album":
if (is_null($id)) {
$id = getAlbumID();
}
$dbtable = prefix('albums');
$doUpdate = getCurrentPage() == 1; // only count initial page for a hit on an album
break;
}
if (zp_loggedin() || $viewonly) { $doUpdate = false; }
$sql = "SELECT hitcounter FROM $dbtable WHERE id = $id";
if ($doUpdate) { $sql .= " FOR UPDATE"; }
$result = query_single_row($sql);
$resultupdate = $result['hitcounter'];
if ($doUpdate) {
$resultupdate++;
query("UPDATE $dbtable SET hitcounter= $resultupdate WHERE id = $id");
}
return $resultupdate;
}

/

Does this look right? or does this code have to be in a different file? BTW i am using the default theme only.

Administrator
Administrator
acrylian   2008-11-27, 18:41
#10

Sorry, I don't understand your issue right now. That is the function where it belongs. You need to add it to your theme files as shown above. Take a look at your theme files how it is done with other functions. Also please read the theming tutorial.

Member
Member
plutusad   2008-11-27, 19:06
#11

thanks again for your help. i have read through the theming tutorial and i am guessing i need to pay attention to the "custom functions" section. From what i understand, i am suppose to insert into the image.php file (assuming i want the hit counter to count my image hits) and then create a new file called customfunctions.php with the above hit counter function in it. This is what i did, and i am sure i did something wrong because it's not working.

Questions:

  1. where do i insert the at in the image.php?
  2. besides the above mentioned hit counter function, do i need to have anything else in the new customfunctions.php file?

Thanks again for your time, and sorry again for my lack of knowledge in this.

Administrator
Administrator
acrylian   2008-11-27, 19:22
#12

No problem with lacking knowledge but you should try to understand some things and maybe learn a little about php. You are on the wrong track right now.

Custom functions are functions you create yourself. Hitcounter is a standard function that is already there. No need to include anything.

Adding a function does actually mean to add the call for the functions, not the function definition itself... This is done with something like this ``. This is really not hard and there are lots of examples in the tutorial.

Member
Member
plutusad   2008-11-27, 19:39
#13

Ah, great...i finally got it...and yes, i was TOTALLY on the wrong track and completely complicated the whole thing. I even got the hitcounter for Albums to work now too. LOL. Thanks again.

Administrator
Administrator
acrylian   2008-11-27, 19:41
#14

Great..:-)

Member
Member
plutusad   2008-11-27, 20:54
#15

Hmm, one more question. I can't get it to work for the "pages", "news", and "categories"...i understand you mentioned above it's different from zenphoto. But again, i don't understand. Thanks for the help.

Administrator
Member
Member
plutusad   2008-11-27, 21:41
#17

i have read that over a few times already...but it doesn't tell me what EXACTLY i have to do as these details is what i am lacking...i think all that is telling me is how to read (interpret) the function, but it doesn't tell me how to get the counters moving.

Administrator
Administrator
acrylian   2008-11-28, 10:09
#18

It actually behaves exactly like the normal Zenphoto hitcounter. Place the function on the additional Zenpage theme files (pages.php, news.php) and set the option to match it.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.