Definition

block_list($region)
drupal/modules/block/block.module, line 397

Description

Return all blocks in the specified region for the current user.

@todo Now that the blocks table has a primary key, we should use that as the array key instead of <i>module</i>_<i>delta</i>.

Parameters

$region The name of a region.

Return value

An array of block objects, indexed with <i>module</i>_<i>delta</i>. If you are displaying your blocks in one or two sidebars, you may check whether this array is empty to see how many columns are going to be displayed.

Code

function block_list($region) {
  static $blocks = array();

  if (!count($blocks)) {
    $blocks = _block_load_blocks();
  }

  // Create an empty array if there were no entries.
  if (!isset($blocks[$region])) {
    $blocks[$region] = array();
  }

  $blocks[$region] = _block_render_blocks($blocks[$region]);

  return $blocks[$region];
}