Drupal: Make regions available from node.tpl.php

<?php
/**
 * Then render any region like
 * <?php print render($region['sidebar_first']); ?>
 */

function mytheme_preprocess_node(&$variables) {

  // Get a list of all the regions for this theme
  foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) {

    // Get the content for each region and add it to the $region variable
    if ($blocks = block_get_blocks_by_region($region_key)) {
      $variables['region'][$region_key] = $blocks;
    }
    else {
      $variables['region'][$region_key] = array();
    }
  }
}

Source: http://goo.gl/ZCdXwK

Leave a Reply

Your email address will not be published. Required fields are marked *