How to embed a region in a node

Embed a Region in a node.tpl.php file (D5)

Last modified: August 26, 2009 - 23:34

By default, drupal provides a number of regions to put blocks in and lets you put them pretty much anywhere in the page you want to. But, there are a few exceptions to this rule. What if you want to put a region in a node? What if you want to put a region in between a node and the comments on that node? This may not seem so easy out of the box. Let's take a look at how to put a region in a node.tpl.php file.

Let's walk through a situation where you want to put a custom region between a node and it's comments. YOu could use this to place something like a block from the Similar by Terms module right under my posting.

Start by adding a custom region called node_region using hook_regions() in your themes template.php file.

<?php
function mythemename_regions() {
  return array(
      
'left_sidebar' => t('left sidebar'),
      
'right_sidebar' => t('right sidebar'),
      
'header' => t('header'),
      
'footer_message' => t('footer'),
      
'content' => t('content'),
      
'node_region' => t('node region'),
  );
}
?>

Syndicate content
 
 

Drupal is a registered trademark of Dries Buytaert.