AdSense Content Injector screen shot

Insert advertisements(or any text/HTML/JavaScript content) into nodes without editing individual nodes or tweaking theme templates. Insert ads or other content in node body or teasers automatically.

*Content Injector was formerly known as AdSense Injector.

Major new features

Reliable in-content insertion using HTML DOM and XPath manipulation

Want to insert ads or other content inside node bodies?

The 6.x-3.x and 7.x-3.x versions for Drupal 6 and 7 now provide reliable in-line insertion into a node's body.

This version provides three body insertion points: top, in-line, and bottom.

The in-line insertion template uses the PHP DomDocument's XPath query feature to select an insertion point. This is powerful, allowing for any valid XPath expression to select the insertion point -- but this also requires that you know what you're doing with XPath if you want to override the default insertion point.

Per-node insertion blocking

There are undocumented features in the 6.x-3.x and 7.x-3.x branches. You can prevent insertion on a per-node basis by adding ai:noinject to the start of a node's body text. See issue #1333800: Document ai:noinject feature: prevent automatic injection in node body of selected nodes. for more info.

In addition, if the node contains any AdSense module [adsense:xxx] manual insertion tags, this module will not inject any ad templates -- so in effect, if you place any AdSense ads using the AdSense module's [adsense] tags, this module's features are disabled for the node in question.

Upgrading from a previous release

The 6.x-3.x and 7.x-3.x branches are fully functional but lack ability to migrate settings from previous versions, so you'll have to reset all your current settings (save copies of your ad templates first!) and re-configure the module.

Call for testers

I need help testing the 6.x-3.x and 7.x-3.x branches new features. Please test and create bug reports if you find any problems.

Module Overview

You can control the node types and word count that will trigger insertion. For example, you can insert content only on "Story" or "Book" (or both) node types, and only if they have more than 300 words. You can use CSS styles to control placement on the page to some extent.

This module allows you to inject content at the top, bottom, or inline in a node's body field when a node is rendered on a full-page view. You can inject content before or after the node's teaser in teaser views. You can inject any arbitrary content you like: text, HTML, JavaScript, whatever.

The AdSense module is required only for [adsense] tag support; if you aren't using [adsense] tags, there is no dependency on the AdSense module as of the 6.x-3.x and 7.x-3.x branches.

This allows site administrators to enable automatic injection of AdSense ads (or other content) into the page without the content editor having to insert inline [adsense] filter tags, or having to edit a site's node.tpl.php (or other template) files. This offers a big advantage, as you can change the ad format, group, and channel on the fly without hand-editing each node.

Module Requirements and Dependencies

At present, the 6.x-2.x versions of this module require the AdSense module in order to support [adsense] tags, though you can inject any text, script, or HTML you like so you are not limited to features found in the AdSense module. This dependency will be removed in an upcoming release.

Known Limitations

Nodes must have a body field with greater than the configured # of words in order to trigger insertion. So, if your node type doesn't have a body field (if you are using CCK to define your own content fields) no insertion will take place. Removal of this limitation has been requested as a feature (see #257406: Support content type without body field.) -- If you want to see this feature added, please visit that issue and register your vote by leaving a '+1' comment.

Development Roadmap

As of December 24, 2011, here are my development priorities in decreasing priority order.

  1. (Done in 6.x-3.x and 7.x-3.x) Flexible insertion options via HTML DOM processing or XPath.

    We'd all like much better control over insertion placement, and I've already created customized versions of this module that allow placement by paragraph count. That's not all we want to do, but it convinced me that this feature would be a great enhancement.

    (See my announcement above, and in issue #141096: Inject adsense into content for details on an experimental release that provides this feature.)

    See #141096: Inject adsense into content and related issues for more information.

  2. (Done) Bug/Issue resolution: Fix critical bugs and resolve open issues where possible.
  3. Integrate simple tests.
    If you would like to create/integrate simpletest tests, let me know. I'll evaluate your tests and integrate them (with full credit/attribution, of course).
  4. Better CCK and Token module support.
    Would be nice to allow insertion as a field rather than modify the node body/teaser.

    Some have requested ability to use CCK fields in insertion template. (?)

    Certainly we want to be able to use the Token module if it's available.

    Another suggestion: Provide a CCK field that contains the rendered injected content (see #602930: Using a CCK field for the Ad_Slot ID?).

  5. Views integration/compatibility (?)

Drupal 7 Version Status

Known issues:

  • 8/15/2011: None at this time.

Maintainer and Sponsorship Information

As of 4/13/2011, the module has a new maintainer. mcurry is the original module author, and is now the official maintainer. Many thanks to rsvelko and hswong3i for their past work as maintainers and co-maintainers.

I may invite co-maintainers as work progresses. Stay tuned.

Project Information

Downloads