MyBB Community Forums

Full Version: Hit Counter on all pages but index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

I'm about to set a hit counter from statcounter.com in all my pages.

They give me two kind of codes: a visible counter and a invisible one.

I just want to show hit counts on index, so I tried to add the invisible code on "footer" template but index takes it as well ,so if I also add the visible one to index, it would be counting me x2 each visitor.

Is there a way to add a code (in this case, hit counter) that takes effects on all pages but index?

thank you for the help you can give me.
Hello?...
Just add the visible one ? Why do you need two counters for ...
LeX- Wrote:Just add the visible one ? Why do you need two counters for ...

Thanks for replying: Because I would like to show the counter only in homepage (index.php), but I also want to count all the other pages, but not showing the counter. So there are two kind of counters (two different codes), so the question is: "How to add a code in all pages but index?"
In global.php, find:
eval("\$footer = \"".$templates->get("footer")."\";");

Before that line, add:
if(basename($_SERVER['PHP_SELF']) == 'index.php')
{
    $mycounter = '<!-- the code for the index page counter -->';
}
else
{
    $mycounter = '<!-- the code for all the other pages counter -->';
}
Thank you Dennis, but one more question... should I also add {$mycounter} to the footer template or something like that, in order to the counter variable "mycounter" takes effect?
Yes that would be a good idea Toungue