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-06 09:11:09

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

Inserting Header HTML

I am wondering if there is a way to insert custom header HTML.  I have some code that I would like on all of my templates... Anyone have thoughts on the best way to incorporate that?


Sitting Pretty in Sunny L.A.

Offline

#2 2015-02-06 09:54:49

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Inserting Header HTML

Yes, you can do this using the phplugins API functions.


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#3 2015-02-06 21:35:00

taog
Member
From: Berlin
Registered: 2015-01-22
Posts: 25
Website

Re: Inserting Header HTML

i do this with the phplugins api and piwik.
piwik script does not work but the piwik image works.

Offline

#4 2015-02-09 04:23:33

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

Re: Inserting Header HTML

I am wishing to put a simple piece of java script in the header or footer of each page.... I am assuming this would be placed in the phplugins.php document. Can I just insert the script below the "/// SET USER FUNCTIONS BLEOW" or would it need special commands to function properly? Thanks for any assistance you can provide!


Sitting Pretty in Sunny L.A.

Offline

#5 2015-02-09 05:25:25

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

Re: Inserting Header HTML

No, you need to direct where on the page the code is going using one of the hooks, like ttg_head_end or ttg_body_bottom
then you use the echo statement to insert the code in that portion of the page

see the phplugins documentation and the examples for how to do this.
http://ce4.theturninggate.net/docs/doku … _phplugins


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

Offline

#6 2015-02-09 05:29:18

taog
Member
From: Berlin
Registered: 2015-01-22
Posts: 25
Website

Re: Inserting Header HTML

rod barbee wrote:

No, you need to direct where on the page the code is going using one of the hooks, like ttg_head_end or ttg_body_bottom
then you use the echo statement to insert the code in that portion of the page

see the phplugins documentation and the examples for how to do this.
http://ce4.theturninggate.net/docs/doku … _phplugins

with the Piwik JAVA Script code the page shown a blank page on my side. with the image tracking code it works.

Offline

#7 2015-02-09 05:31:33

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

Re: Inserting Header HTML

with the Piwik JAVA Script code the page shown a blank page on my side. with the image tracking code it works.

the blank page was probably caused by syntax errors in the code (perhaps single quotes where double quotes were needed)


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

Offline

#8 2015-02-09 05:37:07

taog
Member
From: Berlin
Registered: 2015-01-22
Posts: 25
Website

Re: Inserting Header HTML

rod barbee wrote:

with the Piwik JAVA Script code the page shown a blank page on my side. with the image tracking code it works.

the blank page was probably caused by syntax errors in the code (perhaps single quotes where double quotes were needed)

i copy paste the code from piwik to the section in the php document.

Offline

#9 2015-02-09 05:46:32

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

Re: Inserting Header HTML

i copy paste the code from piwik to the section in the php document.

and it could have contained some sections with single quotes. If you put that after an echo' statement, it will break the page. Those single quotes you got from piwik probably need to be changes to either double quotes or they need to be escaped with a backslash.
nothing wrong with the code by itself, but it probably created a syntax error with the php code it was inserted into.


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

Offline

#10 2015-02-09 05:55:19

taog
Member
From: Berlin
Registered: 2015-01-22
Posts: 25
Website

Re: Inserting Header HTML

This is my code. i am not firm enough with coding. what i have to replace?

<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.XXX.de/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', X]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
    g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<noscript><p><img src="http://www.XXX.de/piwik/piwik.php?idsite=X" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
rod barbee wrote:

i copy paste the code from piwik to the section in the php document.

and it could have contained some sections with single quotes. If you put that after an echo' statement, it will break the page. Those single quotes you got from piwik probably need to be changes to either double quotes or they need to be escaped with a backslash.
nothing wrong with the code by itself, but it probably created a syntax error with the php code it was inserted into.

Offline

#11 2015-02-09 07:59:29

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

Re: Inserting Header HTML

if you've put this code inside of an echo statement, then you'd probably need to escape all the single quotes by placing a backslash in front of them.
for example, this part of your code:

 _paq.push(['trackPageView']);

would need to become this:

 _paq.push([\'trackPageView\']);

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

Offline

#12 2015-02-09 08:08:20

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

Re: Inserting Header HTML

Having the same issue with blank page returned... here is the block I am inserting...

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;
}


Sitting Pretty in Sunny L.A.

Offline

#13 2015-02-09 08:37:09

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

Re: Inserting Header HTML

try escaping all the single quotes other than the one following echo and the last one before the semi-colon before the return false;

What's happening is that the echo statement places whatever is between its single quotes in the page. So that echo ends as soon as it hits the next single quote, the one directly after
document.write {

and the page breaks. Probably because of the code following that single quote.


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

Offline

#14 2015-02-09 08:42:05

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

Re: Inserting Header HTML

Damn! I tried that BEFORE asking, and it did not work, but did it again and now it does... must have missed one the first time... Thanks Much Rod!!!!!!


Sitting Pretty in Sunny L.A.

Offline

#15 2015-02-09 08:46:06

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

Re: Inserting Header HTML

they're easy to miss wink


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

Offline

Board footer

Powered by FluxBB