Javascript and long instruction

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
Philibert
New Member
New Member
Posts: 4
Joined: Mon Mar 24, 2008 2:11 pm

Javascript and long instruction

Post 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
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Javascript and long instruction

Post 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..
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
cyberman

Re: Javascript and long instruction

Post 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}
Philibert
New Member
New Member
Posts: 4
Joined: Mon Mar 24, 2008 2:11 pm

Re: Javascript and long instruction

Post 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!
Post Reply

Return to “Tips and Tricks”