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 2018-02-03 13:01:09

hjrw
Member
From: Peoria (Phoenix) AZ
Registered: 2012-10-01
Posts: 180

Adding a counter to Backlight pages

In CE4, I used some php code to add a 'Statcounter' icon to several pages on my site.  The php code may be seen at this link

https://drive.google.com/file/d/1gRIMsg … sp=sharing

To locate the correct pages, it uses

function ttg_footer_bottom ( $style, $path ) {
    if (G_STYLE == 'CE4-PAGES-HOME') {
        echo '

elseif (G_PATH == 'CLUBS') {
        echo '

elseif (G_STYLE == 'CE4-PAGES-GALLERIES') {
        echo '

Will this work in Backlight?  Are these still appropriate variables to use in Backlight?

Here is a snipit of the php script

// Add statcounter HOME
function ttg_footer_bottom ( $style, $path ) {
    if (G_STYLE == 'CE4-PAGES-HOME') {
        echo '

<!-- Start of StatCounter Code for Default Guide -->
    <script type="text/javascript">
    var sc_project=10262831;
    var sc_invisible=0;
    var sc_security="13728379";
    var scJsHost = (("https:" ==             document.location.protocol) ?
    "https://secure." : "http://www.");
    document.write("<sc"+"ript type=\'text/javascript\' src=\'" +
    scJsHost+
    "statcounter.com/counter/counter.js\'></"+"script>");
    </script>
    <noscript><div class="statcounter"><a title="shopify site
    analytics" href="http://statcounter.com/shopify/"
    target="_blank"><img class="statcounter"
    src="http://c.statcounter.com/10262831/0/13728379/0/"
    alt="shopify site analytics"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->

    ';
    return false;
}

// START NEW CODE

    elseif (G_PATH == 'CLUBS') {
        echo '

<!-- Start of StatCounter Code for Default Guide -->


Thanks,
-Herschel

Offline

#2 2018-02-03 15:08:07

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

Re: Adding a counter to Backlight pages

That won’t work. See the phplugins sample files for the Backlight hooks. Scripts should go in the ttg_scripts hook.

G_PATH and G_STYLE are no longer part of phplugins.

one option is separate page templates using separate phplugins files for each page.

Another is using php to check for a page and insert your script conditionally.

Daniel recently posted some code he uses for conditionally inserting code into specific pages
http://community.theturninggate.net/vie … 056#p51056


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