Community @ The Turning Gate

Support community for TTG plugins and products.

You are not logged in.

#1 2017-11-09 03:28:24

Phoentje
Member
Registered: 2013-10-21
Posts: 117

Ads on shop frontpage

Hi all,

anyone who can assist or guide me how to place google ads on the front webshop page?
Like where and on wich file to place the google code?

Thx

Offline

#2 2017-11-09 03:30:23

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

Re: Ads on shop frontpage

you can probably do that by simply placing the html you get from Google into the page copy field.

If you need it in a specific place, you could use one of the hooks in phphlugins.


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

Offline

#3 2017-11-09 18:41:57

Phoentje
Member
Registered: 2013-10-21
Posts: 117

Re: Ads on shop frontpage

rod barbee wrote:

you can probably do that by simply placing the html you get from Google into the page copy field.

If you need it in a specific place, you could use one of the hooks in phphlugins.

But putting it into the page copy field will make it be inside the shop. Can it be above the shop? Before content?

Offline

#4 2017-11-09 18:59:03

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,604
Website

Re: Ads on shop frontpage

There are PHPlugins hooks for that.


Campagna Pictures, http://campagnapictures.com
The Turning Gate, http://theturninggate.net

Offline

#5 2017-11-29 22:51:32

Phoentje
Member
Registered: 2013-10-21
Posts: 117

Re: Ads on shop frontpage

Matthew wrote:

There are PHPlugins hooks for that.

I am trying to accomplish it right now.. not working very well for me so far.

When I look at the php plugin example I can put my <script> ...</script> after the </php>
Then it works but it will be above everything.

If I try the code into the page copy field it will show me the exact code in text instead of executing it.

When I put the <script> part into function ttg_header_top( $style, $path ) {

}

it will give me a lot of errors... where should I put it ?

Offline

#6 2017-11-29 22:59:23

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

Re: Ads on shop frontpage

You can try placing it with the ttg_scripts hook or the ttg_head hook.

When I look at the php plugin example I can put my <script> ...</script> after the </php>
Then it works but it will be above everything.

don't do this. Place your code inside of a properly formed function inside the USER FUNCTIONS area of the phplugins file.

Does Google offer any suggestions of where to place the code?

Another option: if your design uses a tray, try placing the code in the tray copy area of your template.


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

Offline

#7 2017-11-29 23:07:18

Phoentje
Member
Registered: 2013-10-21
Posts: 117

Re: Ads on shop frontpage

I found this": (this is an example adsense code)

<?php
//assign adsense code to a variable
$googleadsensecode = '
<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 180;
google_ad_height = 150;
//-->
</script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
//now outputting this to HTML
echo $googleadsensecode;
?>


Should I put this into the already present <php> </php> section?
And I translate ttg_header_top as being the posistion that the script is being placed?

Offline

#8 2017-11-29 23:46:17

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

Re: Ads on shop frontpage

take a look inside one of the existing phplugins example files (like phplugins-pangolin-samle.php) in backlight/custom/phplugins/.
At around line 212 you'll see this:

// SET USER FUNCTIONS BELOW
// Some example functions are included below. Feel free to delete or modify unwanted functions.
// 

Below that are example functions that will demonstrate the way to write a function. Substitute the appropriate hook at the top of the function.
Take note of the warning at around line 23 at the top of the file about using single quotes in your code.

you shouldn't need to include those opening and closing php tags: <?php and ?>

ttg_header_top will place content at the top of the header area. This may be where you want the ad to appear. You could also try ttg_masthead_primary_bottom to place it after the masthead.

I'm not sure how your code will work though since there will be two echo statements. It may need go be modified.


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

Offline

#9 2017-11-29 23:54:05

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

Re: Ads on shop frontpage

This seems to work, it creates the space for the ad. But the url to the ad isn't returning anything visible. If you follow the url you'll see no actual html output, it's just a js file.

function ttg_header_top( $style, $path ) { 
	$googleadsensecode = '
<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 180;
google_ad_height = 150;
//-->
</script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
//now outputting this to HTML
echo $googleadsensecode;
	return true;
} // END 

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

Offline

#10 2019-09-12 18:01:06

Phoentje
Member
Registered: 2013-10-21
Posts: 117

Re: Ads on shop frontpage

rod barbee wrote:

This seems to work, it creates the space for the ad. But the url to the ad isn't returning anything visible. If you follow the url you'll see no actual html output, it's just a js file.

function ttg_header_top( $style, $path ) { 
	$googleadsensecode = '
<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 180;
google_ad_height = 150;
//-->
</script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
//now outputting this to HTML
echo $googleadsensecode;
	return true;
} // END 

Hi, I have been using this and worked perfect for me.
Now that I am using the Backlight2 modules for page templates it seem to have broken for me.
I have enabled the PHP plugins in advanced and selected my version of the php file. But it will not showup?

www.circuitpics.nl/webshop

Offline

#11 2019-09-12 21:30:17

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

Re: Ads on shop frontpage

You can’t use your old phplugins file, you’ll need to use the latest version: http://backlight.theturninggate.net/doc … _phplugins
And you’ll need to update your functions to use the new hook syntax. See the latest sample file for the new hooks.


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

Offline

#12 2019-09-13 01:24:56

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

Re: Ads on shop frontpage

Have a look over here fore updating to phplugins for BL2: http://community.theturninggate.net/vie … hp?id=8966


Daniel Leu | Photography   
DanielLeu.com

Offline

#13 2019-09-13 14:58:14

Phoentje
Member
Registered: 2013-10-21
Posts: 117

Re: Ads on shop frontpage

Thanks. I checked both:
This is what I get when I enable the phpplugins.

Too few arguments to function PHPlugins::header_top(), 0 passed in /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-designer/application/helpers/APHPlugins.php on line 63 and exactly 2 expected|#0 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-designer/application/helpers/APHPlugins.php(63): PHPlugins->header_top() #1 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/data/designer/cache/101-page-2.0.0-1-195-menu_14-98-content-2.0.0-6-28-1-admin.view-1.template(218): APHPlugins->dispatch('header_top') #2 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-designer/application/helpers/CacheHelper.php(62): require_once('/customers/f/8/...') #3 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-designer/application/models/GenericEngine.php(575): CacheHelper::includeCachedFile('101-page-2.0.0-...', Array) #4 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-designer/application/controllers/PageController.php(124): GenericEngine->renderView('page', Object(EngineFactory), 'page') #5 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-framework/controllers/Controller.php(56): PageController->view('') #6 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-framework/models/Dispatchable.php(136): Controller->dispatch(Array) #7 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/backlight/modules/module-framework/Framework.php(73): Dispatchable->dispatch() #8 /customers/f/8/a/circuitpics.nl/httpd.www/webshop/index.php(38): Framework->route() #9 {main}|URL: /webshop/index.php


And this is what my file looks like.

<?php
/*
*  TTG Core Elements "PHPlugins" User Hooks v1.2 - initialization mainline
*
*  developed by john bishop images (http://johnbishopimages.com)
*  for Matthew Campagna of The Turning Gate (http://theturninggate.net)
*
*/

function user_load($style, $path) {
  $g_tsvrl = explode(' ', $style); // Extract gallery type
  define ('G_STYLE', strtoupper($g_tsvrl[1])); // and set global for later
  $g_path = str_ireplace('\\','/',$path); // change \ to /
  $chunks = explode('/',$g_path); // and put into array
  define ('G_PATH', strtoupper($chunks[count($chunks)-2])); // gallery folder name is second to last
  //define ( 'TTG_SITE', ''); // set new site root for navigation, resources, etc.
}

if (defined('BACKLIGHT_HOOK')) {
    require_once(realpath(BACKLIGHT_HOOK).'/modules/module-designer/application/helpers/APHPlugins.php');
}

class PHPlugins extends APHPlugins
{
/*
*
*  *************************************************************************************
*  *                                                                                   *
*  * Warning! When using echo or print special care must be qiven to using quotes.     *
*  *                                                                                   *
*  * Strings inside single quotes must contain only double quotes                      *
*  * or all single quotes must be escaped (ie \') or vice-versa                        *
*  *                                                                                   *
*  *************************************************************************************
*
*  Fourteen user exits are defined in all web engines - all are optional
*    (i.e. user_load.php may be the only processing)
*
*  Some web engines will have additional exits defined, specific to that gallery type
*
*  Each is called with the same parameters:
*    %1  - TTG gallery-style gallery-release
*        3 blank delimited values
*        - %1.1  - 'TTG'
*        - %1.2  - string describing gallery type; no embedded blanks
*        - %1.3  - a series of two to three period delimited integers
*              describing gallery release level; x.y or x.y.z
*    %2  - server filesystem file name and path of calling file
*
*
*  Defined exits:
*
*    user_load
*      - return value ignored
*      - called immediately after this file returns
*      - called before any output is produced
*      - all header and response variables are accessible
*      - cookie and session processing can be initialized
*      - globals to be used by later hook calls can be defined
*
*    head
*      - return value ignored
*      - called immediately before </head>
*      - encompasses nothing; use to insert content into the <head>
*
*    header_top
*      - if return=false, the contents of the normal Backlight header are skipped
*      - called immediately within the header section
*      - encompasses the full contents of the header section; can be used to replace those contents
*
*    header_bottom
*      - return value ignored
*      - called last in the header section
*      - encompasses nothing; use to insert content at the end of the header section
*
*    masthead_primary_top
*      - if return=false, normal Backlight masthead is skipped
*      - called immediately before the masthead element
*      - fully encompasses the masthead; can be used to replace it
*
*    masthead_primary_bottom
*      - return value ignored
*      - called immediately after the masthead
*      - encompasses nothing; use to insert content after the masthead
*
*    masthead_secondary_top
*      - if return=false, normal Backlight masthead is skipped
*      - called immediately before the masthead element
*      - fully encompasses the masthead; can be used to replace it
*
*    masthead_secondary_bottom
*      - return value ignored
*      - called immediately after the masthead
*      - encompasses nothing; use to insert content after the masthead
*
*    navigation
*      - if return=false, normal Backlight navigation is skipped
*      - navigation is separate from the header section, so not affected by the above header... hooks.
*      - encompasses the navigation <ul> element; can be used to replace it
*
*    main_top
*      - return value ignored
*      - called immediately within the main content column
*      - encompasses nothing; use to insert content at the very top of the main content column
*      - located outside the password protected area
*
*    main_bottom
*      - return value ignored
*      - called immediately before closing the main content column
*      - encompasses nothing; use to insert content at the very bottom of the main content column
*      - located outside the password protected area
*
*    footer_top
*      - if return=false, the contents of the normal Backlight footer are skipped
*      - called immediately within the footer section
*      - encompasses the full contents of the footer section; can be used to replace those contents
*
*    footer_bottom
*      - return value ignored
*      - called last in the footer section
*      - encompasses nothing; use to insert content at the end of the footer section
*
*    pallet_top_title
*      - if return=false, the encompassed code is skipped
*      - wraps the site title in the top pallet
*      - use to replace the site title
*
*    toggle_T1
*      - if return=false, the encompassed code is skipped
*      - wraps the label element for "page__toggle__T1"
*      - use to replace the toggle button with one of your own making
*
*    toggle_T2
*      - if return=false, the encompassed code is skipped
*      - wraps the label element for "page__toggle__T2"
*      - use to replace the toggle button with one of your own making
*
*    social_top
*      - if return=false, normal content is skipped
*      - called immediately before social media icons in the top pallet
*      - encompasses the social media icons; can be used to replace them
*
*    social_bottom
*      - return value ignored
*      - called immediately after social media icons in the top pallet
*      - encompasses nothing; use to insert content following the social media icons
*
*    scripts
*      - return value ignored
*      - called immediately before </body>
*      - encompasses nothing; use to insert content at the very bottom of the page
*
*    copy_top
*      - if return=false, normal copy is skipped
*      - called immediately within the page copy area
*      - encompasses the page copy; can be used to replace it
*
*    copy_bottom
*      - return value ignored
*      - called immediately before closing the page copy area
*      - encompasses nothing; use to insert content following the page copy
*
*    pallet01_top
*      - if return=false, pallet content is skipped
*      - called within pallet01, after masthead and navigation
*      - encompasses the pallet01 content area
*
*    pallet01_bottom
*      - return value ignored
*      - called after the pallet01 content
*      - encompasses nothing; use to insert content at the end of pallet01
*
*    pallet02_top
*      - if return=false, pallet content is skipped
*      - called within pallet02, after masthead and navigation
*      - encompasses the pallet02 content area
*
*    pallet02_bottom
*      - return value ignored
*      - called after the pallet02 content
*      - encompasses nothing; use to insert content at the end of pallet02
*
*    albumset_top
*      - if return=false, normal copy is skipped
*      - called immediately within the media area
*      - encompasses the gallery grid / slideshow; can be used to replace it
*
*    albumset_bottom
*      - return value ignored
*      - called immediately before closing the media area
*      - encompasses nothing; use to insert content following the gallery grid / slideshow
*
*    album_top
*      - if return=false, the album content is skipped
*      - called immediately within the media area
*      - encompasses the album grid / slideshow; can be used to replace it
*
*    album_bottom
*      - return value ignored
*      - called immediately before closing the media area
*      - encompasses nothing; use to insert content following the album grid / slideshow
*
*    single_top
*      - if return=false, single image and content are skipped
*      - called immediately above the single image display
*      - encompasses the single image and related metadata; can be used to replace it
*      - available only on single-image HTML pages for applicable album templates
*
*    single_bottom
*      - return value ignored
*      - called after the single image display
*      - encompasses nothing; use to insert content following the single image display
*      - available only on single-image HTML pages for applicable album templates
*
*/

// SET USER FUNCTIONS BELOW
// Some example functions are included below. Feel free to delete or modify unwanted functions.
// ****************************************************************************************************



/* DELETE THIS LINE
// Basic structure for a PHPlugins function
function _HOOK_() {
    echo '

    ';
    return false;
} // END /**/



/* DELETE THIS LINE
function navigation() {
    echo '
    <ul class="primary-menu menu">
        <li class="menu-item"><a href="/">Home</a></li>
        <li class="menu-item menu-item-has-children"><a href="/galleries">Galleries</a>
            <ul class="sub-menu">
                <li class="menu-item"><a href="">Sub-item 1</a></li>
                <li class="menu-item"><a href="">Sub-item 2</a></li>
            </ul>
        </li>
        <li class="menu-item"><a href="/about">About</a></li>
        <li class="menu-item"><a href="/contact">Contact</a></li>
    </ul>
    ';
    return false;
} // END
DELETE THIS LINE */



// ****************************************************************************************************
// END USER FUNCTIONS
function header_top( $style, $path ) {
    $googleadsensecode = '
<center><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Circuitpics_shop -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-3043054831309820"
     data-ad-slot="5079864734"
     data-ad-format="auto"></ins>

<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></center>';
//now outputting this to HTML
echo $googleadsensecode;
return true;
} // END
} ?>

Offline

#14 2019-09-13 15:07:37

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

Re: Ads on shop frontpage

please read my post again....

2) Function names changed and lost their arguments. You only need to remove the ttg_ prefix and whatever is between parentheses.

So

function header_top( $style, $path ) {

becomes

function header_top() {

Daniel Leu | Photography   
DanielLeu.com

Offline

#15 2019-09-13 16:55:06

Phoentje
Member
Registered: 2013-10-21
Posts: 117

Re: Ads on shop frontpage

Daniel Leu wrote:

please read my post again....

2) Function names changed and lost their arguments. You only need to remove the ttg_ prefix and whatever is between parentheses.

So

function header_top( $style, $path ) {

becomes

function header_top() {

Could not translate "parentheses", but now I understand.
It looks like it got the default page working now. http://www.circuitpics.nl/webshop/

If I now want to also have this visable in the galleries and albums I have to create those functions seperate albumset_top and album_top? Or can this be put in the same function?

Offline

#16 2019-09-13 21:29:09

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

Re: Ads on shop frontpage

Are your album and album set templates using the same page template as your web shop page?
If not, activate the same phplugins file for the page template being used for your album and album set templates.


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

Offline

Board footer

Powered by FluxBB