Returns all blocks in the specified region for the current user.
$region: The name of a region.
An array of block objects, indexed with the configuration object name that represents the configuration. 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.
function block_list($region) {
$blocks =& drupal_static(__FUNCTION__);
if (!isset($blocks)) {
global $theme;
$blocks = array();
foreach (entity_load_multiple_by_properties('block', array(
'theme' => $theme,
)) as $block_id => $block) {
$blocks[$block
->get('region')][$block_id] = $block;
}
}
// Create an empty array if there are no entries.
if (!isset($blocks[$region])) {
$blocks[$region] = array();
}
return $blocks[$region];
}