Profile picture for user admin
Daniel Sipos
23 Sep 2013

Update 23 September: I’ve been doing a bit of feature work on my module Block Inject. If you don’t know about the module yet, please see below what it does - there’s a screencast and everything.

7.x-1.2

This release makes Block Inject the most powerful it has ever been. If you are unhappy with the default placement of the injected region (middle of the body field), you can specify a number of paragraphs as an offset in any direction you want (up or down) to move it - on an individual node basis. Basically you now have the power to adjust it according to the content in that node.

The exceptions overview now includes information on the offset you have for individual nodes. It tells you whether the exception stops the injection or if it doesn't, how many paragraphs it is offset by.

Additionally, I fixed a couple of reported bugs, one of which now making it possible to use Block Inject on multilingual sites as well. It works both with the core translation solution and the Entity Translation module (which is the recommended approach).

So give it a try and let me know if you encounter any problems.

7.x-1.1

What I did in the 7.x-1.1 release was added the possibility to override the block region being injected into individual nodes. This means that if you set up a region to be injected in all the nodes of a type, you can then manually override this individually for each node. Let’s say if you are writing an article in which you do not want the injected block to appear, all you have to do is check a box.

To manually override this you have to edit a node and under the Publishing options you will see another checkbox: Remove the Block Inject effect on this node. If you tick this box and save the node, the region won’t be injected into this node. Naturally this checkbox will only be available for the content types for which there is a region to be injected.

Additionally, you get an overview page at admin/structure/block-inject/exceptions where you can see all the nodes for which the injection is exempted.

This new feature adds a bit more flexibility to the use of the module. Now you have the option that if for some reason a piece of content does not need the injection, you can prevent this from happening and know that for the rest of the nodes all is copacetic.

The alternative to this would have had you edit the block assigned to the injected region and set it to not display on a particular node page. But what if you have 3 blocks in the region and you need to stop them from showing on 15 nodes over time? With the new feature, everything is controlled at the node edit level and you also get an overview of which nodes are exempted from injection.

I want to work a bit more on making Block Inject even more flexible by allowing the site administrator to select into which text fields of a content type should the region be injected. Currently it goes into the body field by default but if your main text body is located in a custom field, the module won’t help you. So this will be a next step.

Probably after that, I will make it possible to override the placement of the injected region per node. Currently the default is in the middle of the node body field. This is done by calculating the number of paragraphs (<p>) and injecting it half way. However, it would be good to allow the content editor to move it up or down a couple of paragraphs for individual nodes if the situation requires it. Come to think of it, I might even work on this next :)

So if you can, test it out and fire up the issue queue with bugs and problems you may have - after all, the module is still in its alpha stage.

Block Inject - What Is It?

Block Inject is a simple module that lets you create custom block regions that get inserted automatically in the middle of all the nodes of a certain type. The idea for it stems from a previous article of mine in which I talked about how you can add content in the middle of the node body field.

It is very simple to use: you create a region to which you assign one or more node types. Then, you add blocks to that region with whatever content you want. These blocks will then appear in the middle of all the node bodies of the content type you assigned to that particular region. There is also a fail-safe: if the body field does not contain at least 2 paragraphs, no blocks get injected. Pretty cool and simple.

And of course, you can individually overwrite some things in the block configuration - for instance make the block display only for certain roles, on certain paths etc.

So do check it out, test it, let me know if you find any bugs or something.

Thanks a lot!

Profile picture for user admin

Daniel Sipos

CEO @ Web Omelette

Danny founded WEBOMELETTE in 2012 as a passion project, mostly writing about Drupal problems he faced day to day, as well as about new technologies and things that he thought other developers would find useful. Now he now manages a team of developers and designers, delivering quality products that make businesses successful.

Contact us

Comments

Daniel Sipos 09 Apr 2013 18:16

Thanks for the support and

Thanks for the support and comment!

Sean Robertson 30 Apr 2013 00:00

Awesome

You'll be pelase to know that this was perfect for a very big project we're working on right now. It's a port of an existing large news site to Drupal and they a newsletter subscription block buried in the body of every page. It'll be a couple months before the site is done, but you save us a headache with this one. :-)

Daniel Sipos 30 Apr 2013 10:46

In reply to by Sean Robertson (not verified)

Hehe, glad to do it!

Hehe, glad to do it!

Thanks for your comment!

Witek 18 Dec 2013 00:11

One little change this module...

Hello Danny. Great job! It's almost fantastic, but how i can set paragraph? I don't want put ads only in middle on my article. What do you think?

Daniel Sipos 19 Dec 2013 20:49

In reply to by Witek (not verified)

Hey there,

Hey there,
Thanks for the interest in my module. As I mention in the article, the latest release I created the possibility to override the placement of the ad per individual node. So you can choose to bring it higher or lower by a number of paragraphs.

D

Witek 21 Dec 2013 00:12

One little change this module...

I have 7.x-1.2-alpha2 version, but i can't override the placement of the ad per individual node. Where is it this feature?

Daniel Sipos 21 Dec 2013 11:31

Did you have a previous

Did you have a previous version before and upgraded to this one? If so, did you run the database updates and everything?

The place to override the placement is on the node edit form. When you add/edit a node of the content type for which there is a injection.

D

Dr Anaolics 17 Jun 2014 06:08

Thanks

Thanks for adding this module, didn't know it existed and it is exactly what I am looking for

Sergey Shevgota 12 Jul 2014 09:14

Paragraph formatting

Great decision! Thank you, this is the right module!
On my site, widely used text formatting.
On those pages where applied paragraph formatting (eg

), the block is not displayed. Can I fix it somehow?

Best regards, Sergey Shevgota.

brad mclaughlin 24 Oct 2014 01:36

Block inject DFP ad tags and responsive?

Is there a possibility of making this inject a block based on the size of the browser? I am trying to get a DFP (ad) into the article if the screen is mobile-sized. Is this possible?

Sergey Shevgota 28 Oct 2014 17:35

In reply to by admin

Block responsive

In Block Inject file block_inject.module delete a line 304

</ div>
Then, using the module Block Theme, assign block style:
.insert {
float: right;
width: 37%;
max-width: 304px;
margin: 5px 0 5px 10px;
padding: 0;
}
Holly 07 Mar 2016 23:52

Is only one inject region allowed for a content type?

Hi,
Your module is just what I needed and so easy to use! However, I'm trying to put adsense ads in multiple places within the content. Is that possible?

Thanks.

Add new comment