Stupid Template Tricks

Note: This page describes the 2.5 and later releases

Consider the default node insertion template (formatted for readability):

<div class="ad-auto-inserted" style="float:left; margin: 0 1em .25em 0;">
[adsense:120x240:1:1]
</div>
%body
<br class="clear"/>
[adsense:468x60:1:1]

On full node views, this will insert a 120x240 left-floating ad block before the node body, then, after the body text, a 468x60 ad will be appended, both ads using the adsense module's group 1 and channel 1 settings.

Now, then, what else can we do? How about putting an ad on both the left and right side of the top of the node, as well as at the bottom? We can do that very easily, using inline float styles (for the purposes of this example - it's cleaner to use stylesheet-defined CSS rules).

(Yes, this is probably annoying in-your-face advertising, and I wouldn't recommend it, but it serves to demonstrate capabilities.)

<div class="ad-auto-inserted" style="float:left; margin: 0 1em .25em 0;">
[adsense:120x240:1:1]
</div>
<div class="ad-auto-inserted" style="float:right; margin: 0 0 .25em 1em;">
[adsense:120x240:1:1]
</div>
%body
<br class="clear"/>
[adsense:468x60:1:1]

Give it a try.

Obviously, you can play a lot of tricks with the template strings - for example, you can insert any arbitrary text before or after the node body, including html, javascript, etc. The sky (and your imagination) is the limit, just be careful not to break anything. (At this point, the adsense_injector module can do more than just inject ads using the new template scheme.)

Please see the adsense module help and documentation for more information on the filter tag and ad formats available for use.

Inserting adsense after teaser

Thomasr976 - October 26, 2007 - 16:21

Just installed this wonderful Adsense Injector Module which will make my life much easier. Have read everything I can on it. I have inserted adsense after each teaser on the frontpage. However I am having trouble installing it afte the teaser on the full node. What modifications to the code below should I be making if I want it below the teaser.

<div class="ad-auto-inserted" style="float:left; margin: 0 1em .25em 0;">
[adsense:120x240:1:1]
</div>
%body
<br class="clear"/>
[adsense:468x60:1:1]

Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.