How can I get the hit counter on the image page?

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

  • place `echo getHitcounter();` where you want the counter to appear.
  • Hi sbillard!

    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
  • acrylian Administrator, Developer
    Within html code of course the second...
  • Okay, tested this already. I doesn't show up. Can it be that difficult?
    ...
  • acrylian Administrator, Developer
    The question is also where exactly you placed the call. It needs to be in an image or album context. Otherwise it will not work.
  • As said: in the image.php, line 58, 59 of the default zenphoto theme.

    `
    <?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 printHomeLink('', ' | '); ?>" title="<?php gettext('Albums Index'); ?>"><?php echo getGalleryTitle();?>
    | <?php printParentBreadcrumb("", " | ", " | "); printAlbumBreadcrumb("", " | "); ?>
    <?php printImageTitle(true); ?>




    <?php if (!checkForPassword()) { ?>


    <? 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 if (getOption('Use_Captcha')) {
    $captchaCode=generateCaptcha($img); ?> <?php } ?>

    ( /> <?php echo gettext("don't publish"); ?>)
    " class="inputbox" />
    " class="inputbox" />
    " class="inputbox" />
    "/>
    /> <?php echo gettext("Private (don't publish)"); ?>
    <?php echo $stored['comment']; ?>

    " class="pushbutton" />




    <?php } else { echo gettext('Comments are closed.'); } ?>
    <?php printRSSLink("Comments-image","",gettext("Subscribe to comments"),""); } ?>

    <?php } ?>


    <?php printRSSLink('Gallery','','RSS', ' | '); ?> <?php printCustomPageURL(gettext("Archive View"),"archive"); ?> |
    <?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.
  • acrylian Administrator, Developer
    IF that code is right, you got a space between the question mark and the "php". This actually should result in an error.

    Anyway, it is working as expected with the recent release. I just tried.
  • Sorry no, there is no space between the question mark and the "php". Pasting code here is a little tricky. The counter's just not showing up. Can I check some other things that are connected to the counter appearence in the page?

    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 ...
  • acrylian Administrator, Developer
    Alright, just wanted to be sure.

    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.
  • I has. I just has 10 hits. In the database, too. No error logs. As I see the php doesn't make it to the hatml generated page. Have you a page, where I can have a look at the hit counter?

    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.
  • Well, no. The hitcounter is just a number--the number of visits (by non-admin users) toi the site. The Effervescence+ theme has hitcounters in the footer of the pages.
  • Okay, seen that.
    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.
  • So, if you select the Effervescence+ theme, do the hitcounters show up in the footer? getHitcounter() is declared in the template-functions.php script. Zenphoto Functions Guide in the User Guide section of the Zenphoto WEB site which would have told you this.)

    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.
  • Hi sbillard!

    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:
    `



    `
  • You must be making some basic error. As I said above, the echo statement will display something even if it does not display the counter. Since you get nothing. You must not be actually doing what you think you are doing.

    So, be sure that you are making the changes to the theme you are actually running, etc.
  • NOW!
    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
  • I putted this one and works well :)

    [ <?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/
Sign In or Register to comment.