You are here

function _block_load_blocks in Drupal 7

Loads blocks' information from the database.

Return value

An array of blocks grouped by region.

1 call to _block_load_blocks()
block_list in modules/block/block.module
Returns all blocks in the specified region for the current user.

File

modules/block/block.module, line 732
Controls the visual building blocks a page is constructed with.

Code

function _block_load_blocks() {
  global $theme_key;
  $query = db_select('block', 'b');
  $result = $query
    ->fields('b')
    ->condition('b.theme', $theme_key)
    ->condition('b.status', 1)
    ->orderBy('b.region')
    ->orderBy('b.weight')
    ->orderBy('b.module')
    ->addTag('block_load')
    ->addTag('translatable')
    ->execute();
  $block_info = $result
    ->fetchAllAssoc('bid');

  // Allow modules to modify the block list.
  drupal_alter('block_list', $block_info);
  $blocks = array();
  foreach ($block_info as $block) {
    $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
  }
  return $blocks;
}