SMF Support > SMF 2.0.x Support

Insert some code into template

(1/1)

gregy:
Hi guys

I would like to add some code that will collect some statistic, but i keep getting error.

Code is;

--- Code: ---<script type="text/javascript">
<!--
var r = Math.random();
var t = new Date();
document.write("<img width='1' height='1' src='http://domain.com/nc/px.gif?site=name&t=" + t.getTime() + ";r=" + r + "'>");
// -->
</script>
<noscript>
<img width="1" height="1" src="http://domain.com/nc/px.gif?site=name&js=0">
</noscript>

--- End code ---

The code above generates error

--- Quote ---Template Parse Error!
There was a problem loading the /Themes/default/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
--- End quote ---

Thank you for your help

ccbtimewiz:
Single quotes need to be escaped.

Do it like this:


--- Code: ---echo '
<script type="text/javascript">
<!--
var r = Math.random();
var t = new Date();
document.write("<img width=\'1\' height=\'1\' src=\'http://domain.com/nc/px.gif?site=name&t=" + t.getTime() + ";r=" + r + "\'>");
// -->
</script>
<noscript>
<img width="1" height="1" src="http://domain.com/nc/px.gif?site=name&js=0" alt="*" />
</noscript>';

--- End code ---

gregy:
it works .. thank you very much!

Navigation

[0] Message Index

Go to full version