You are here

function esi_block_page_alter in ESI: Edge Side Includes 7.3

Implements hook_page_alter().

File

modules/esi_block/esi_block.module, line 37
ESI handler for blocks.

Code

function esi_block_page_alter(&$page) {

  // The block system hard-codes some aspects of block information
  // in _block_get_renderable_array().
  // ESI blocks need to:
  // - Remove the contextual-links data.
  // - Remove the 'block' theme wrapper.
  foreach (element_children($page) as $region_key) {
    foreach (element_children($page[$region_key]) as $block_key) {
      if (isset($page[$region_key][$block_key]['#block']) && is_object($page[$region_key][$block_key]['#block']) && !empty($page[$region_key][$block_key]['#block']->esi_enabled)) {

        // Remove contextual-links.
        unset($page[$region_key][$block_key]['#contextual_links']);

        // Remove the theme wrapper.
        unset($page[$region_key][$block_key]['#theme_wrappers']);
      }
    }
  }
}