Hi at zenphoto forums!
I just saw that's possible to have a hit counter for the images, galleries on the page. How can that be done? I saw that I can reset the counter on the admin page but it does not appear on my site. I'm using 1.2.5 and default theme with some modifications. There's no "enable hit couter" button as far as I see.
I just tried this:
http://www.zenphoto.org/support/topic.php?id=4812#post-28263 , but the counter does not show up.
What do I have to do to make the hit counter appear? I noticed that it's already included but needs to be activated.
Thanks for help,
FM
Comments
Thanks for the quick answer. Nope, it doesn't appear.
I placed it between the div tags in line 57/58 in the image.php of my (default) theme. So it should be below the image before the comment form, right?
Honestly I must admit that I know HTML, but my knowledge in php is pretty llimited.
Is it really `echo getHitcounter();` or is it
`<? php echo getHitcounter(); ?>`
My best regards,
FM
...
`
<?php if (!defined('WEBPATH')) die(); $themeResult = getTheme($zenCSS, $themeColor, 'light'); $firstPageImages = normalizeColumns('2', '6');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php zenJavascript(); ?>
<?php echo getBareGalleryTitle(); ?> | <?php echo getBareAlbumTitle();?> | <?php echo getBareImageTitle();?>
" type="text/css" />
/js/thickbox.css" type="text/css" />
/js/thickbox.js" type="text/javascript">
function toggleComments() {
var commentDiv = document.getElementById("comments");
if (commentDiv.style.display == "block") {
commentDiv.style.display = "none";
} else {
commentDiv.style.display = "block";
}
}
<?php printRSSHeaderLink('Gallery',gettext('Gallery RSS')); ?>
<?php if (hasPrevImage()) { ?>
<?php } if (hasNextImage()) { ?>
<?php } ?>
<?php printHomeLink('', ' | '); ?>" title="<?php gettext('Albums Index'); ?>"><?php echo getGalleryTitle();?>
| <?php printParentBreadcrumb("", " | ", " | "); printAlbumBreadcrumb("", " | "); ?>
<?php printImageTitle(true); ?>
<?php if (!checkForPassword()) { ?>
" title="<?php echo getBareImageTitle();?>">
<?php
if (function_exists('printUserSizeImage')) {
printUserSizeImage(getImageTitle());
} else {
printDefaultSizedImage(getImageTitle());
}
?>
<?php if (function_exists('printUserSizeImage')) printUserSizeSelectior(); ?>
<? php echo getHitcounter(); ?>
<?php printImageDesc(true); ?>
<?php if (function_exists('printSlideShowLink')) printSlideShowLink(gettext('View Slideshow')); ?>
<?php
if (getImageEXIFData()) {echo "<div id=\"exif_link\">".gettext("Image Info")."
printImageMetadata('', false);
}
?>
<?php printTags('links', gettext('<strong>Tags:').' ', 'taglist', ''); ?>
<?php if (function_exists('printImageMap')) printImageMap(); ?>
<?php if (function_exists('printRating')) { printRating(); }?>
<?php if (function_exists('printShutterfly')) printShutterfly(); ?>
<?php if (getOption('Allow_comments')) { ?>
<?php $num = getCommentCount(); echo ($num == 0) ? "" : ("<h3>".sprintf(gettext('Comments (%u)'), $num)."
"); ?>
<?php while (next_comment()){ ?>
<?php printCommentAuthorLink(); ?>
<?php echo getCommentBody();?>
<?php echo getCommentDateTime();?>
<?php printEditCommentLink(gettext('Edit'), ' | ', ''); ?>
<?php }; ?>
<?php if (OpenedForComments()) { ?>
<?php echo gettext("Add a comment:"); ?>
<?php
printCommentErrors();
$stored = getCommentStored();
?>
( /> <?php echo gettext("don't publish"); ?>)
$captchaCode=generateCaptcha($img); ?>
" class="pushbutton" />
<?php } else { echo gettext('Comments are closed.'); } ?>
<?php printRSSLink("Comments-image","",gettext("Subscribe to comments"),""); } ?>
<?php } ?>
<?php printZenphotoLink(); ?>
<?php if (function_exists('printAdminToolbox')) printAdminToolbox(); ?>
`
So in my understanding it should appear between the image and the comment box on each image.
Anyway, it is working as expected with the recent release. I just tried.
Looks like this: http://img18.imageshack.us/img18/6766/zwischenablage01xso.jpg
I believe you that it works. It's just not working on my page, so I try to find out why ...
Did you look at the database? Does that image actually have a hitcount? Are there any errors in the error log? I have no other ideas.
One more question to make shure we're talking about the same thing: Is the hit counter the thing with the stars taht float to yellow wenn hovering them? The rating tool like "I give three of five stars for that image." or is the hit ounter - tht I don't see - something that tells me "100 People have already seen this picture", so it pints out "100" below the image?
I'd name the first one rating tool the other one hit counter.
For that theme it appears on the image page.
They realized it by a special part by an extra customfunctions.php.
`
<?php
switch ($page) {
case 'image':
$h = getHitcounter();
echo "".sprintf(ngettext('%1$u hit on this image','%1$u hits on this image',$h),$h)."
";
break;
case 'album':
$h = getHitcounter();
echo "".sprintf(ngettext('%1$u hit on this album','%1$u hits on this album',$h),$h)."
";
break;
case 'gallery':
?>
`
I placed that in my image.php and index.php. Still no positve result.
Where is getHitcounter declared, so that it can be echoed on the page?
I'm still on it.
The above code will echo `something` so long as you are on an image or album page. So if you are not seeing any output only two things can be wrong. You are not on an image or album page or you have place the code somewhere that is being hidden. I suggest you look at the page HTML to see if the text is there.
Well, I placed the counter call over twenty times in the image.php and album.php page. It doesn't show up. It even doesn't make it to the HTML page. There's no indication in the source code.
At the end of page I have the following:
`
`
So, be sure that you are making the changes to the theme you are actually running, etc.
I got it. You're right, sbillard. I was editing the wrong theme AND didn't made any modification due to the album layout theme.
The album layout theme was set to [blank] = no theme selected.
I made my changes to the image.php and album.php on ..\default.
As the album indecated "zenpage-dault" as the choosen theme I thought I was right. But as I had choosen [blank] to any album as selected theme, it didn't made it to the page.
Now after I recognized tthat there's a 'default' theme and a 'zenpage-default' theme I finally realized that I was editing 'default' all the time and not 'zenpage-default'. Setting every album to 'zenpage-default' and editing the image.php and album.php of THIS theme in ..\zenpage-default brought the counter on the page.
Thanks for the directions!
Now I have to struggle setting it up to the right appearence layout.
Greetz,
FM
[ <?php echo gettext("Original Size:"); ?>
<?php echo getFullWidth() . "x" . getFullHeight(); ?> px ]
<div></div>
[ <?php
$h = getHitcounter();
echo "".sprintf(ngettext('%1$u - hit','%1$u - hits',$h),$h)."
";
?> ]
http://darek.fr/