How can I add google adsense

magicphoto

Joined: 2006-09-28
Posts: 1
Posted: Thu, 2006-09-28 15:52

Hi,

I found instructions on how to add google adsense to both footer and header. However, I'd like to add a google adsense banner to the right side of the pic when being viewed (post clicking on the thumbnail). How can this be done?

Thanks again for your help!

Magic

 
baloch4

Joined: 2007-02-19
Posts: 8
Posted: Fri, 2007-03-02 06:51

I think this is the best way to place google ads anywhere you want to place it on your gallery and i asure you that it works you can see it on my site http://www.junkinside.com/picture-gallery/

The page is missing one vital element for the novice coder. You need to surround your google addstuff with single quotes.

I will use myself as an example, just because I know what I did:

First off, you can see this working at http://www.junkinside.com/picture-gallery/

I went to google and requested some text add scripts, went through and got the settings for a vertical and a horizontal banner.

Than I went to my gallery/themes/matrix/templates directory and created a new directory called local.
Then I went to gallery/themes/matrix/templates/local and created a new file, adsense-sidebartext.tpl
Following the instructions on that page, I set my tpl file as follows:
{php}
$adcode = '<script type="text/javascript"><!--
google_ad_client = "pub-8608778378338793";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "text";
google_ad_channel = "";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo $adcode;
{/php}

Please note, I'm following the instructions on that page precisely,
$adcode = <<<END
HERE COMES YOUR GOOGLE BANNER CODE (its better to use 468x60 size)
END;

However, what I'm doing is surrounding my adcode in single quotes. It seemed logical to me and it worked, but then I am halfway familiar with PHP.

I followed the same process to create a footer template, only calling it adsense-footertext.tpl

Now, the next step is to COPY the album.tpl, photo.tpl, and sidebar.tpl from the template directory to the local directory. IE from gallery/themes/matrix/templates to gallery/themes/matrix/templates/local

Now, you will only edit the files in the local directory! Edits to the templates directory will be ignored.

To add a sidebar under the random image, I edited sidebar.tpl
Turning this
{g->block type="core.NavigationLinks" class="gbBlock"}
</div>
into this
{g->block type="core.NavigationLinks" class="gbBlock"}
{g->theme include="adsense-sidebartext.tpl"}

</div>

To add the footer to the main window(but I wanted it IN the window, not at the page bottom] I edited 2 templates:
album.tpl
Changing this
{/foreach}
</div>
</td>
</tr>
</table>
To this
{/foreach}
{g->theme include="adsense-footertext.tpl"}
</div>
</td>
</tr>
</table>

To add a footer underneath the full sized photo's I edited photo.tpl, changing
{g->block type="core.EmergencyEditItemLink" class="gbBlock"
checkSidebarBlocks=true
checkPhotoBlocks=true}
</div>
</td>
</tr>
</table>
to this
{g->block type="core.EmergencyEditItemLink" class="gbBlock"
checkSidebarBlocks=true
checkPhotoBlocks=true}
{g->theme include="adsense-footertext.tpl"}
</div>
</td>
</tr>
</table>

So that is the basics. Similiar actions can be taken for the top and footer.

Advanced functionality I want to look into

1) Display a sidebar of ads next to an image(since many of my images don't fill the screen)

2) Display google ads in the midst of an list of thumbnails when viewing an album, or in the middle of a list of albums.

Of the two, I am likely to do the former, but unlikely to do the latter since I truely don't want the ads showing up in my own personal album there, I just want to do it as an exercise in learning how to do it.

 
bigu_c
bigu_c's picture

Joined: 2007-10-28
Posts: 421
Posted: Mon, 2007-10-29 15:23

detected: Trojan program Trojan-Clicker.JS.Agent.h URL: http://www.junkinside.com/picture-gallery/main.php//main