I'm trying to insert a block inside of a node. The problem is that I want it to appeat automatically after a paragraph X, preferably after the first paragraph.
AdSense Injector module (http://drupal.org/project/adsense_injector) is quite useful, but it isn't very flexible, because you can only insert one code. Since I plan to insert different blocks in different situations, I would like to insert a region after a first paragraph.
There is a tutorial (www.werockyourweb.com/drupal-insert-adsense-ads-into-middle-of-content) that doesn't seem to work for Drupal 7.
Here is visual explanation:
<h1>Title</h1>
<p>Some text here</p>
<div>BLOCK INSIDE OF THE NEW REGION</div>
<p>Some text here</p>
Could someone please offer some guidelines?
EDIT:
Here are the codes I'm using.
Block code:
<h2>Is this working?</h2>
.info file:
regions[testing] = 'Testing'
Template.php
function THEMENAME_preprocess_node(&$variables) {
//load your adblock
$testing = block_load('block', '1');
$output .= drupal_render(_block_get_renderable_array(_block_render_blocks(array($testing))));
$variables['ad'] = $output;
}
Node.tpl.php
<?php
$array = explode("</p>", $body[0]['value']);
$array[1] = $ad. $array[1];
$content['body'] = implode("</p>", $array);
print render($content['body']);
?>