I'm trying to add a custom block right below the content of each post BUT can't get the block to print out. This is what i've done so far.

I have added the following to the .info file

regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[belowPost] = Below Posts

and in my node.tpl.php file just before the last "div" close tag I've added the following:

<?php print $belowPost ?>

The problem is when I assign a block to this region, nothing really prints out on the node. What am I missing?

Thanks for your help.


nevets’s picture

I think regions are still only in page.tpl.php by default. You may also want to check out http://drupal.org/node/171224. Check out the list under "A few notes", particularly item 4 about caching of the .info file.

CompShack’s picture

I think regions are still only in page.tpl.php by default
Do you know how can I get the custom region to print to node.tpl.php?

I read that page and it doesn't help. I can see my new block in the block administration page but the content assigned to the new block area is not being displayed on the nodes.

I think i need to add something to the template.php file but not sure what. In Drupal 5 i had to modify function _phptemplate_variables($hook, $vars) to load region content assigned via the new blocks.

I have also read this "Keep in mind that the internal names are converted into region variables inside the "page.tpl.php" template automatically." This means outputting the region on node.tpl.php is not done automatically. SO, what am i missing?

Finally, I CMS that I Like!

wladimirww’s picture

Theme settings (region is "settings" too) are cached in theme registry. Try to disable, and enable again your theme.
My Drupal 6 livin' here

CompShack’s picture

double post - sorry

CompShack’s picture

I will try that when i get home tonight, but I don't think this would work the reason being when I put the print $belowPost command in page.tpl.php the blog gets printed out ok but when i put it in node.tpl.php it doesn't show on the node at all. Anyone know why?

Finally, I CMS that I Like!

CompShack’s picture

Can anyone plz tell me what i'm doing wrong. I just can't get my custom region to print on node.tpl.php - it prints fine on the page.tpl.php though.

this is my code from node.tpl.php

  <div class="content clear-block">
    <?php print $content ?>
    <?php print $belowPost ?>

Finally, I CMS that I Like!

CompShack’s picture

i had to add the below code to my template.php and it worked GREAT

function phptemplate_preprocess_node(&$vars) {
	if (!$vars['teaser']){
         foreach (array('belowPost') as $region) {
         $vars[$region] = theme('blocks', $region);

Finally, I CMS that I Like!

vojnar’s picture

Thanks for this post! It works how it should!

Weboldal Készítés Weboldal.biz

petrovichby’s picture

That's what I need! Thanks!

holger’s picture

Thank you very much, it works well in drupal 6.6 and the garland theme.

best wishes from germany, Holger

IT-News und IT-Jobs auf w3Projekt.com

OpenChimp’s picture

Sweet. There's another article that explains how to do this: http://www.codegobbler.com/drupal-6-how-embed-region-node

Since you don't need to include all regions, there doesn't seem to be a need for the foreach loop. Just declare each variable.

function phptemplate_preprocess_node(&$vars) {
  $vars[$region] = theme('blocks', 'belowPost');
  $vars[$region] = theme('blocks', 'abovePost');

And then just print the variable in your node-______.tpl.php file.

if (!$teaser) {
  print $belowPost;
r.aubin’s picture

Your solution didn't work for me until I realized that I needed to put in my variable name instead of $region.

For example:

function phptemplate_preprocess_node(&$vars) {
  $vars['myBlockName'] = theme('blocks', 'myBlockName');

After that change, I was able to call my custom region from my node template.

蜡笔小新’s picture

got it, thanks a lot

mattwmc’s picture

I'm having the same problem - trying to print a region in the user profile.

My region is named: staffmenu

Block is named: staff_links

What do I need to put in the above code to make it work? And then place in the user-profile.php?

This isn't working:


function phptemplate_preprocess_node(&$vars) {
if (!$vars['teaser']){
         foreach (array('staffmenu') as $region) {
         $vars[$region] = theme('staff_links', $region);


<?php print $staffmenu; ?>


lsabug’s picture

this saved me loads of time and popped right up in a search!

jbates_oi’s picture

I really do.
Thanks for this super-simple solution.

rahul_sankrit’s picture

Place this stuff where want to print the regions.

  $module = "block"; // Here is the module name like view, block etc here i am using block.
  $region = 'contentbottom';  //place region name.
  $sql_object = db_query("SELECT * FROM {blocks} WHERE region= '%s'", $region);
  $block = db_fetch_object($sql_object);
  $delta = $block->delta;
  $block = module_invoke('block', 'block', 'view', $delta);
  // print $block['content'];

Kumar Rahul Sankrit