[Drupal] How to get a block inside a node in Drupal 6?

| | 1 min read

Getting a block in front page or in all other pages is easy ie, we only need to print that variable in our template files namely page-front.tpl.php or in page.tpl.php.In certain cases we may need to print a block in certain nodes. This can be done by the following code :

function phptemplate_preprocess_node(&$vars, $hook) {
  $vars['right_block'] = theme('blocks', 'right');
  $vars['content_top_block'] = theme('blocks', 'content_top');

Place the above code in our template.php, replace 'themeName' by our theme name.

Let us narrow down here, in the above code 'right_block' and 'content_top_block' are the two variables.'right' and 'content_top' are the two regions.Here we are assigning the blocks in those two regions to the variables 'right_block' and 'content_top_block'.