I didn't realize how hard this was going to be. It's easy to add adsense to a block within drupal. But to actually add the adsense within content is tricky.
I found a solution for adding adsense to drupal pages. The great thing about the solution is that you can blend a 336x280 ad into the content with wrap around text wrap. You can place a couple of ads as well and the adsense unit will insert on the top and botton of the page.
First, download, install and activate the adsense and contemplate modules.
Second, create a php file with the code below and install to sites/all/contemplates/node-story-body.tpl.php
Should you want the ads to appear on a blog then the file should be named node-blog-body.tpl.php
Find the full instructions here
Code:<?php $decoration1 = adsense_display(array('format' => '120x90', 'slot' => '4243067992')); $decoration2 = adsense_display(array('format' => '250x250', 'slot' => '0335368690')); $content = explode("</p>", $node->body); for ($i = 0; $i < count($content); $i++) { if ($i == 0 ) { ?> <div style="float:left;margin-right: 5px;"> <?php print $decoration1; ?> </div> <?php } if ($i == 1) { ?> <div style="float:right;margin-left: 5px;"> <?php print $decoration2; ?> </div> <?php } print $content[$i] . "</p>"; } ?>


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks