Community Documentation

Content Injector (AdSense Injector) Insertion Template Tricks

Last updated November 14, 2011. Created by mcurry on March 17, 2007.
Log in to edit this page.

Note: This page describes the 2.5 and later releases up to 6.x-2.x and the 7.0 release. Later releases use a different insertion template format.

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.

Comments

How i can do ... ? random:

How i can do ... ?

random: [adsense:120x240:1:1], [adsense:250x120:2:1], [adsense:120x120:1:2]

%body


[adsense:468x60:1:1]

random: [adsense:120x240:1:1], [adsense:250x120:2:1], [adsense:120x120:1:2]

Not at present.

No, not at present. Care to submit a feature request?

Page status

About this page

Drupal version
Drupal 4.7.x, Drupal 5.x, Drupal 6.x, Drupal 7.x
Audience
Site administrators, Themers
Level
Intermediate
Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here