You are here

function _regions_blocks in Regions 7

Same name and namespace in other branches
  1. 6 regions.module \_regions_blocks()

Helper function to get a list of blocks per region.

Parameters

string $region_name: The region identifier.

array $region_info: An individual element child of the array returned by _regions_list().

Return value

A string containing the rendered blocks for this region.

See also

_regions_list()

regions_footer()

1 call to _regions_blocks()
regions_page_alter in ./regions.module
Implements hook_page_alter().

File

./regions.module, line 163
Add regions to the screen that are cross-theme compliant

Code

function _regions_blocks($region_name, $region_info) {

  // Update the {block} table with the blocks currently exported by modules.
  $blocks = array();
  if (module_exists('context') && function_exists('context_get_plugin')) {
    $blocks = context_get_plugin('reaction', 'block')
      ->block_list($region_name);
  }
  else {
    $blocks = block_list($region_name);
  }

  // Allow other modules to alter the blocks array before the each block object
  // is rendered by theme_block().
  drupal_alter('regions_blocks', $blocks, $region_name);

  // Render the array of blocks using either an optional module-provided
  // callback, or the default theme('block', $block).
  $render_callback = isset($region_info['render_callback']) && function_exists($region_info['render_callback']) ? $region_info['render_callback'] : 'theme';
  $output = '';
  foreach ($blocks as $block) {
    $output .= call_user_func_array($render_callback, array(
      'block',
      $block,
    ));
  }
  return $output;
}