Downloads
Release notes
OVERVIEW
This version integrates a number of features I've been working on over the last year or so. It is intended to address issue #141096: Inject adsense into content and #1301610: Remove AdSense module dependency, and provide a platform for ongoing new feature development.
If you are upgrading from 6.x-2.x versions, please read the known issues/installation notes, below!
MAJOR NEW FEATURES as of October 6, 2011
- Now supports XPath-based insertion for inline ad insertion.
The default XPath expression is /html/body/p[3] which will insert the inline ad insertion template *after* the third paragraph of the node body, at the root level. This avoids insertion inside nested (descendant) elements.
At present, insertion is always done using ->appendChild() method of the element returned as a result of the XPath expression. This means that it's impossible to insert _before_ the found element. This limitation may be lifted in a future release.
- "Top" and "bottom" insertion.
You can now specify "TOP" and "BOTTOM" insertion templates, which will be inserted at the top or bottom of the node body, respectively. This method uses the body's 'content' fields with weights (top = -6, and bottom = 10).
There is no way to alter these weights via the adsense_injector admin settings page, but you can set the variables 'adsense_injector_front_weight' and 'adsense_injector_back_weight' manually if you like. (Note: These variable names are likely to change in the future if and when these weights are exposed via the admin settings page.)
- Manual (per-node) insertion point control.
Now supports manual insertion point selection (using a new [ai:insertion:inline] tag). The 'inline' template will be inserted at the point where this tag appears.
- Manual blocking of injection on a per-node basis:
Now supports manual "no inject" (using thecomment or other occurance of 'ai:noinject' within first 512 characters of node body.)
Note that HTML comments are filtered out by the HTML filter and other filters, so you might need to use something like
or any other HTML tag allowed by the node's input filter. (Oh, it would be so nice if Drupal's core HTML filter and HTML Corrector filter allowed HTML comments to pass through...)
See: #222926: HTML Corrector filter escapes HTML comments
and #103563: HTML filter escaping html comments - Removed AdSense module dependency.
That's right, you don't need the AdSense module to use AdSense Content Injector. If you don't have the AdSense module enabled, you won't be able to use the [adsense:xxx] tags in your templates. You can use raw JavaScript to inject Google AdSense ads. Your choice.
See: #1301610: Remove AdSense module dependency
Installation notes and known issues
BEFORE YOU INSTALL THIS VERSION
For users of the 6.x-2.0 release or 6.x-2.x dev branch:
NOTE: You should perform and test the upgrade procedure on a development or test server before upgrading a production server - which is always recommended in the case of a major feature upgrade.
If you've previously installed and used the AdSense Injector module 6.x-2.7 (or any earlier release), after installing and enabling the 6.x-3.0 version you must use the Reset to defaults button in the AdSense/Content Injector admin settings to reset the module's settings in order to configure AdSense/Content Injector properly. See issue #1342142: Cannot configure node body insertion template settings after upgrade to 6.x-3.0 and the fix, here.
Failure to update the insertion template settings during the upgrade will result in insertion of the new default templates, which are probably the wrong format and will use a bogus ad slot id -- and your site visitors will see ads you don't want them to see, and you probably won't get any ad revenue!
This release does not automatically update your node body insertion templates! If someone would like to submit a patch to implement such upgrade functionality, I'll gladly test it and consider incorporating it into the project, but, at present, this is a very minor manual procedure and not worth the trouble IMO.
Before installing the 6.x-3.x versions, you should disable node body insertion in page views and save a copy of your old page view insertion templates (copy and paste them from the settings page into a text editor) before you upgrade to this version. This will allow you to update module settings after you install the 6.x-3.x version, before re-enabling the node body insertion.
You will have to re-enter node insertion template settings to use your desired ads or other inserted content. The template syntax has changed (the %body token no longer available or necessary). Copy your old insertion template into a text editor before you install this version, remove the %body token, and update the template settings as appropriate, using the default values as a guide. (The current default value is <div style="float: right; margin: 0; padding: 0 1em .25em 0;">[adsense:250x250:0123456789]</div>, which, assuming the AdSense module is enabled, will place a 250x250 block ad on the right side of your node content, using the placeholder ad unit id 0123456789. If the AdSense module is not installed or enabled, site visitors will just see the unprocessed filter block [adsense:250x250:0123456789]. This default value will be changed in a future release.)
So, the general update process from 6.x-2.x (or earlier) versions to the 6.x-3.x-dev or 6.x-3.0 build:
- Copy your old body and teaser list insertion template text for future reference -- you're going to lose it during the update!
- Disable the old version of the module.
- Delete the old version's files.
- Install and enable the new version in the usual way.
- Reset the module's settings to default values.
- Re-enter your teaser template and update the module's "Inline insertion" template to reflect your desired inline template (which will probably be based on your old "body insertion template").
- Re-select the node types to allow insertion as desired.
- Set the word count limits as appropriate.
Altering insertion points using XPath
The default inline insertion point is after the third top-level paragraph of the node (this is controlled by the inline insertion XPath pattern field.) You can change this by altering the XPath pattern. I will write up a handbook page about this soon.