[SOLVED] Help with inserting Adsense banner between album items

mcemrn

Joined: 2013-02-17
Posts: 20
Posted: Thu, 2013-10-24 20:24

Hi everybody, i need help inserting an Adsense banner ( Banner 468 x 60 ) between the items of the album, precisely after three items, please see the screenshot attached.

I think i have to modify the file \themes\wind\views\album.html.php
But it's not simple for me because i am a beginner in coding...

I hope someone can help me, Michele

AttachmentSize
Cattura.PNG429.32 KB
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2013-10-25 03:36

This could be converted to a module but this should work for now. Add:

<script>
$(document).ready(function() {
$('#g-advert-code').insertAfter('#g-album-grid li:nth-child(3)');
});
</script>
<li id="g-advert-code"><div>advert code goes here</div></li>

to the bottom of \themes\<your theme>\views\album.html.php

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mcemrn

Joined: 2013-02-17
Posts: 20
Posted: Fri, 2013-10-25 09:55
floridave wrote:
This could be converted to a module but this should work for now. Add:

<script>
$(document).ready(function() {
$('#g-advert-code').insertAfter('#g-album-grid li:nth-child(3)');
});
</script>
<li id="g-advert-code"><div>advert code goes here</div></li>

to the bottom of \themes\<your theme>\views\album.html.php

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Oh Thanks floridave! You are fantastic, thanks for the code!
But i have a problem, the adsense banner will load properly in browsers Internet Explorer and Mozilla Firefox but... it won't load(after first page visited) in browsers Google Chrome, Opera and Safari in fact it will load only if i click F5 button!

Please help

EDIT: I tested some browsers...
WILL WORK ON: Internet Explorer 8, Internet Explorer 10, Mozilla Firefox

WON'T WORK ON: Google Chrome, Internet Explorer 9, Opera, Safari

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2013-10-25 13:43
Quote:
WON'T WORK ON: Google Chrome, Internet Explorer 9, Opera, Safari

Works for me in Chrome and IE10 and Safari 5.17 windows.

Does standard text and html work in the <div>advert code goes here</div> without the goofy js and iframe stuff from your advert banner?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mcemrn

Joined: 2013-02-17
Posts: 20
Posted: Fri, 2013-10-25 20:22
floridave wrote:
Quote:
WON'T WORK ON: Google Chrome, Internet Explorer 9, Opera, Safari

Works for me in Chrome and IE10 and Safari 5.17 windows.

Does standard text and html work in the <div>advert code goes here</div> without the goofy js and iframe stuff from your advert banner?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Ok the standard example text "advert code goes here" work good and display properly in all the browsers i tested like Chrome, Firefox, IE 8,9,10, Opera and Safari.

But when i put my Adsense Banner 468x60 between the tags <div></div> the banner will show (in browsers Chrome, IE 9, Opera, Safari) only the first page, then when i surf the gallery and change album the banner won't show anymore and only a blank div is showed unless i click F5 button.
I am 100% sure that the Adsense Banner is active and work properly because i use the same Banner 468 x 60 in other gallery pages...

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2013-10-26 01:18

I tried a few things with jquery and iframes......some luck with iframes but the TOS get in the way.
OK the only way to do this without breaking the TOS of google adsense is:
Edit \themes\<your theme>\views\album.html.php
find: <li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">
and before that add:

  <? if($i==3) { ?>
  <li>google advert code here</li>
  <? } ?>

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mcemrn

Joined: 2013-02-17
Posts: 20
Posted: Sat, 2013-10-26 06:28
floridave wrote:
I tried a few things with jquery and iframes......some luck with iframes but the TOS get in the way.
OK the only way to do this without breaking the TOS of google adsense is:
Edit \themes\<your theme>\views\album.html.php
find: <li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">
and before that add:

  <? if($i==3) { ?>
  <li>google advert code here</li>
  <? } ?>

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

Thanks, now the code works 100% on every browser! Thanks for the time! Thanks, Thanks, Thanks