I have the same problem in the Default theme, if I add `<?php hitcounter("image", false); ?>` in the code, or if I echo the value, it always stays at 0/zero. Any ideas?
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): Increments (optionally) and returns the hitcounter if a page is viewed (image.php and album.php only).
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/
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.
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 <?php require_once('customfunctions.php'); ?> 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 <?php require_once('customfunctions.php'); ?> 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.
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 `<?php hitcounter("image", false); ?>`. This is really not hard and there are lots of examples in the tutorial.
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.
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.
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.
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.
Comments
Thanks !
Increments (optionally) and returns the hitcounter Does not increment the hitcounter if the viewer is logged in as the gallery admin
http://www.zenphoto.org/documentation-official/zenphoto/_template-functions.php.html#functionhitcounter
Increments (optionally) and returns the hitcounter if a page is viewed (image.php and album.php only).
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
/
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.
Questions:
1) where do i insert the <?php require_once('customfunctions.php'); ?> 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.
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 `<?php hitcounter("image", false); ?>`. This is really not hard and there are lots of examples in the tutorial.