I'm working with a custom theme (which I did not develop.) We're wanting to add a block to a specific node type, which has a template called node-session.tpl.php. This template prints out all kinds of internal html and php, but is framed by the page.tpl.php file. The node-session.tpl.php contains the code that's printed by the $content variable in page.tpl.php.

I have a new block (created by the AddThis module) that needs to be positioned on the page such that it's nested inside a div created in the node-session.tpl.php. Unfortunately placing the region inside that file doesn't work, and in fact just testing for the variable $add_this itself returns false. According to all the documentation I can find, region variables are available to page template files only. Is there a way I can make the variable available to the node-session.tpl.php file so that I can position the block correctly?

1 Answer 1


Sure, you can use a node_preprocess() hook to create the variable much like this:

function mytheme_preprocess_node(&$variables) {

   // whatever else you are doing goes here

   $block = module_invoke('AddThis', 'block', 'view', 0);


which would call the AddThis module to invoke it's block hook and return block with delta 0.

Lots more detail can be found here: http://www.pixelclever.com/how-insert-a-block-a-tpl-or-content-programmatically-with-drupal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.