Community & Support

Adding Regions to node.tpl.php in D6

I'm trying to add an inline block region to my node.tpl.php file that will display a block in my node content that's floating to the right.

As many Drupal Devs know the region variable is not available in the node.tpl.php file. So I did some digging and found something for Drupal 5.x that supposedly works but I'm having a hard time getting it to work on Drupal 6. My reason for doing this is so that the region can be dynamic and only displayed on certain content type pages, but also act as if it's a part of the content making it harder for the user to miss.

Here's the link to the article to make this happen in 5.x: http://drupal.org/node/29139

And here's the code from the article that I put in my template.php file:

<?php
function _phptemplate_variables($hook, $variables) {
 
// Load the node region only if we're not in a teaser view.
 
if ($hook == 'node' && !$vars['teaser']) {
   
// Load region content assigned via blocks.
   
foreach (array('content_internal') as $region) {
     
$variables[$region] = theme('blocks', $region);
    }
  }
  return
$variables;
}
?>

My region name is "content_internal." Anyone know what might need to be done to get this to work? I'm not getting in WSOD or errors, just nothing... :)

Comments

_phptemplate_variables not around any more

this function is not available in drupal 6, for the new methods you can start here:

http://drupal.org/node/223430

this is my guess without researching:

<?php
function template_preprocess_node(&$vars) {
 
// Load the node region only if we're not in a teaser view.
 
if ( !$vars['teaser']) {
   
// Load region content assigned via blocks.
   
foreach (array('content_internal') as $region) {
     
$vars[$region] = theme('blocks', $region);
    }
  }
  return
$vars;
}
?>

Thanks!

That worked out perfectly! Thanks!

nobody click here