View Full Version : counting php pages
doubleclick
08-18-2004, 02:14 PM
Turns out most of my site consists of php pages
Since I have no <body> </body> tags to insert StatCounter code between, how to I add code to these pages to count their stats?
thanks
webado
08-18-2004, 02:24 PM
When your php pages are rendered in the browser they must have a <body> ... </body> tag. This will be inserted at times from an html template of sorts or coded in php for this purpose in some common files.
You'll have to find those palces where the <body> or </body> tag are inserted and work at putting your counter in there.
If it's in an html template, this is easy, you just paste the counter code generated by Install right there.
If it's in php itself, you'll have to adapt the counter code to php using echo .
doubleclick
08-18-2004, 02:27 PM
Thanks Christina, but you seem to have mistaken me for someone who knows php. :shock:
Could you please explain your last statement? Maybe even an example?
If it's in php itself, you'll have to adapt the counter code to php using echo .
Nice websites by the way. As a compulsive link-clicker, I've been meandering through the ones your signature leads to...
webado
08-18-2004, 03:00 PM
LOL! No problem.
First off, are the php files stored on your web site? Because otherwise you cannot change them in any way.
Are we talking forum software here or what exactly? How did the php site get created?
Anyway, if you have access to those files and they are on your pc (download them all if not), perform a search in Windows explorer on the folder where you have them and look for anything that contains <body> or </body>. If you're lucky this will be contained in 1 or 2 files.
I prefer to place my counter right before </body> so I'll give you an example done like this.
Say you've found the </body> text in file abc.php. Open abc.php using Notepad, find the </body> . If it's in an html portion (as php files can in fact be html files with some php scripting), then just add normal html code for your counter, save and you're in business.
If you find the </body> in a php construct like:
echo '</body>';
or maybe
echo ('</body>');
or perhaps it is even written as:
print '</body>';
They are all the same.
Then add just before that line:
// **** added customization for Statcounter code ****
echo '<center>';
echo '<script type="text/javascript" language="javascript">';
echo 'var sc_project=999999;';
echo 'var sc_partition=1;';
echo 'var sc_invisible=0;';
echo '</script>';
echo '<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script>';
echo '<noscript>http://c2.statcounter.com/counter.php?sc_project=999999&java=0 (http://www.statcounter.com) </noscript>';
echo '</center>';
// **** end customization for Statcounter
Notice how in fact the code generated by Install Counter is present but each line is preceded by echo ' and followed by '; . This is how you instruct php to output html code.
Very important: Since I used .. instead of ... here so that I can add colors to the code, make sure you do not actually split the line:
echo '<noscript>http://c2.statcounter.com/counter.php?sc_project=999999&java=0 (http://www.statcounter.com) </noscript>';
on 2 or more lines as it appeared above. This means have it all as one continuous line from echo with just single blanks separating the words, until the ;
What I have in blue you will have to adapt to your own project number, of course.
What I have in green is my way of centering the code, but you can use <p align="center"> ... </p> or other methods.
I hope this helps.
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.