Page 1 of 1

Javascript and long instruction

Posted: Sat Jun 21, 2008 11:24 am
by Philibert
Hello everybody,

I would like to insert a Google Analytics instruction on my pages.
http://www.philibert.ch
I thought that could be easier to create a user tag instead of typing the whole code in every page...

The instruction I received from Google Analytics is

echo '';
...

The problem is that the 3rd line is cutted in the CMSMS editor (like here) and is understood as a new line. Then I got the error message
# Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/www/ea1e6a33c37a3beb702c4802b7843447/web/cmsms/admin/adduserplugin.php(94) : eval()'d code on line 3

My question: How could I tell CMSMS that instruction on line 3 continue on line 4?

Thank you in advance,
Philippe Roth

Re: Javascript and long instruction

Posted: Sat Jun 21, 2008 1:13 pm
by kermit
Philibert wrote: I thought that could be easier to create a user tag instead of typing the whole code in every page...
that's what global content blocks are for..

make one with the html and/or smarty code you want to include...

add a call to it in your page template...

{global_content name='nameofyourgcbhere'}

then you're done.

OR, you can just put the code directly in your template.. but using a global content block allows easier use on multiple templates and having to edit it only once if it changes.

using a udt instead just adds a little extra work as you have to php-ify the html code google gave ya.

note.. if you did a copy/paste of that code you included in your post, double-check your single & double quotes..

Re: Javascript and long instruction

Posted: Sat Jun 21, 2008 3:31 pm
by cyberman
Insert this before your ending tag

Code: Select all

{literal}
<__script__ type="text/javascript"><!-- 
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//--></__script>';
{/literal}

Re: Javascript and long instruction

Posted: Sat Jun 21, 2008 3:49 pm
by Philibert
Hello Kermit,

Thank you very much for the light  :)
It works wonderfully  ;D
You helped me to better understand CMSMS.

Have a nice week-end,
Phil

PS: I use CMSMS since a while, but I find it marvelous! It's community too ;) Great job!