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?
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
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]"
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.
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
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.
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:
Thanks again for your time, and sorry again for my lack of knowledge in this.
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.