I want to display a block which should ideally appear in the <?php print $content?> are of a node.

The block is already there and assigned to a region.

The problem I am having is inserting that region into the +body output+. The problem is that nothing shows.

I am using the following in Affect body output

<?php if ($regionname) { ?>
<?php print $regionname;?>
<?php } ?>

Comments

jrglasgow’s picture

Status: Active » Postponed (maintainer needs more info)

Which block are you trying to add to the body? Can you give me an example to work with, it is much easier for me to think when I have an example.

Also this code is much cleaner than the code you have listed.

<?php
  if ($regionname) {
    php print $regionname;
  }
?>
jrglasgow’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

since this has ben inactive for 33 weeks I am going to mark this closed.

mediamash’s picture

have to reopen it again

function _phptemplate_variables($hook, $variables) {
  // Load the node region only if we're not in a teaser view.
  if ($hook == 'node') {
    // Load region content assigned via blocks.
    foreach (array('region_1_here', 'other_region_here') as $region) {
      $variables[$region] = theme('blocks', $region);
    }
  }
  return $variables;
}

only works for the node template which are located in the theme root, not in the contemplate folder ...

mediamash’s picture

Status: Closed (fixed) » Active
planctus’s picture

Version: 5.x-1.8 » 6.x-1.1
Component: Documentation » Code

Hello, is there any way to insert a custom region in a contemplate's node template file?
I mean, as mediamash, i'm speaking about the templates placed inside the contemplate folder in sites/all/contemplates.
In a specific situation i need to use that template instead of a node-nodetype.tpl.php in the theme folder, that specific case is a simplenews' newsletter node type
I was trying to use the usual way , a preprocess function in the template.php with a switch for the node types

phptemplate_preprocess_node(&$vars) {
  switch ($node->type) {
case 'mynodetype' :
foreach (array('customRegion') as $region) {
      $vars[$region] = theme('blocks', $region);
    } 
break;
}

but nothing happened, i'm going to investigate if the problem is the theme being used by the template, otherwise i don't know how to do this...
Thanks,
Da.

jrglasgow’s picture

the $regions aren't built for the nodes in the preprocess function, only in the page preprocess function.

it looks to me like you might be better served by using panels.

planctus’s picture

Your answer really surprised me...
You can use any theming hook you like to place variables in using a preprocess function...
http://drupal.org/node/223430

I always use this way to place my custom regions in a node template when i need it, so there must be a different explanation and it must depend on the way contemplates' templates are built.
If i place that region in the simplenews-newlsetter-body.tpl.php suggested by simplenews it works fine, indeed, but i need to use the contemplates' template in this case...

I guess that the mediamash's post pointed in the same direction but it was based on drupal 5 while i'm using drupal 6, but the issue should be the same: apparently we can't insert a region inside a contemplates' template file.

Thanks,
Da.