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.

Comments

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.

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!
http://www.CompShack.com

-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

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

__________________________________
My Drupal 6 at Radio Site

double post - sorry

-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

I will try that when i get home tonight, but I don't think this would work the reason being when I put the

<?php
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?

Thanks!
-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

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 ?>
  </div>

-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

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!
http://www.CompShack.com

-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

Thanks for this post! It works how it should!

Webdesign
Weboldal Készítés Weboldal.biz

That's what I need! Thanks!

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

best wishes from germany, Holger

IT-News und IT-Jobs auf w3Projekt.com

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;
}

Michael Thorne

Mikey,
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.

got it, thanks a lot

PHP开源系统,目前我只用Drupal...

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:

tempate.php:

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

user-profile.php:

<?php print $staffmenu; ?>

Thanks.

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

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