Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2015-02-12 02:30:02

hursey
Member
From: Los Angeles
Registered: 2012-12-07
Posts: 113
Website

Inserting scripts

I have a script that I want on all of my pages. I tried inserting it in the phplugins.php in the "Set User Functions Below" using the tag-body_bottom tag but the script appears to fall outside of the "SCRIPTS" area and consequently does not function...

Any thought would be much appreciated!

Sample Page is www.hursey.com/clients/tutorial....

Script is :

function ttg_body_bottom( $style, $path ) {
echo '
            <script type="text/javascript">
  /* <![CDATA[ */
  document.write (
    \’<img src="http://photography.hursey.com/acton/bn/13476/visitor.gif?ts=\'+
    new Date().getTime()+
    \’&ref=\’+escape(document.referrer) + \’”>\’
  );
  var aoAccountId = \’13476\’;
  var aoCookieMode = \’STANDARD\’;
  var aoCookieDomain = \’hursey.com\’;
  var aoServerContext = \’http://photography.hursey.com/acton\';
  /* ]]> */
</script>
';
    return false;
}

Last edited by hursey (2015-02-12 02:30:52)


Sitting Pretty in Sunny L.A.

Offline

#2 2015-02-12 04:02:58

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Inserting scripts

the script is appearing where it's expected, at the body bottom. That it's outside that Scripts comment area doesn't matter.

check the script itself.

Maybe someone with more Javascript knowledge will come along to troubleshoot the script.

Are this: /* <![CDATA[ */  and this /* ]]> */ supposed to be commented out like that?


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#3 2015-02-12 04:11:04

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Inserting scripts

what I'm seeing in the script is that the escape characters \ are included (except for the very last one).
But if you don't escape them in phplugins, the page will likely break.
Hmmmm


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#4 2015-02-12 05:04:10

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Inserting scripts

I see the problem. It's the single quotes in the script. If you look closely nearly all of them are slanted except for two:
the one in this part of the code: /visitor.gif?ts=\'+
and the one at the end in this part of the code: \’http://photography.hursey.com/acton\'
and those are the only two single quote marks that appear correctly in the script in the page source.

notice that the single quote preceding http above is slanted and the one following acton\ is straight.

I suggest putting this code back into a plain text editor and replacing all the slanted quotes with straight quotes. Some text editors have slanted quotes. I'm using Notepad ++ and it has straight quotes and will fix this.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#5 2015-02-21 03:37:03

hursey
Member
From: Los Angeles
Registered: 2012-12-07
Posts: 113
Website

Re: Inserting scripts

Just a quick follow up as an FYI.. I have resolved this issue... partly with the great assistance provided above.. however the script was still not functioning... Finally I switched the function from "body_bottom" to "body_top" and it now functions perfectly.

Thanks!!!


Sitting Pretty in Sunny L.A.

Offline

Board footer

Powered by FluxBB