Last Updated: February 25, 2016
·
655
· robinvdvleuten

Create a block in a node.tpl.php file

Declare the region in your theme's .info file:

regions[node_footer] = Node - Footer

In a templatepreprocessnode function, add the necessary code to get the blocks for our defined region:

/**
 * Implements template_preprocess_node().
 */
function THEMENAME_preprocess_node(&$variables) {
    if ($blocks = block_get_blocks_by_region('node_footer')) {
        $variables['node_footer'] = $blocks;
    }
}

Now you can render the region in the node.tpl.php file like this:

<?php if (isset($node_footer)): ?>
    <div class="region-node-footer">
        <?php print render($node_footer); ?>
    </div>
 <?php endif; ?>