We developed Hop Inject to solve a very common but tricky problem: We wanted to place an advertisement after the 3rd paragraph on a page. But, since this is EE we’re talking about, of course the 3rd paragraph was in a custom field of an entry, and it was hard to add at run time. In addition, we thought, what if we wanted to add a photo after the 4th paragraph? Or a pull quote after the 6th and 9th? What if we want to let editors add images into stories wherever they want, but they don’t know HTML? (Shocking, I know.)
Hop Inject does the trick. It lets you specify where an injection should occur (such as, “on paragraph tags”); it lets you specify which of those separators should get the injection (for example, “the third and the eighth”); and it lets you specify what the injection should be. It also lets you choose whether the injection should occur before or after the separator.
Sound like a problem you’ve run into, too? Well, it’s not a problem anymore!
This version is compatible with EE 2.1.3 and later (and probably NOT with 2.1.1 and earlier).
Version 1.2 adds the ability to inject counting up from the bottom of a block of content, as well as down from the top.
Credit: This was inspired by Leevi Graham’s LG Replace but we didn’t want to have to include search markers in the body content; that plugin gives you exact targeting, but this plugin keeps your data uncluttered and re-useable.
Current Version Notes
2.1.0 Fixed a case where always_inject was set to ‘yes’ but there were no instances of the thing at all to find. Other cleanup, too.