You are here

function esi_context_context_load_alter in ESI: Edge Side Includes 7.3

Implements hook_context_load().

File

modules/esi_context/esi_context.module, line 56
ESI integration for the context module.

Code

function esi_context_context_load_alter(&$context) {

  // Iterate all the blocks displayed in a context reaction.
  if (!empty($context->reactions) && !empty($context->reactions['block']) && !empty($context->reactions['block']['blocks'])) {
    foreach ($context->reactions['block']['blocks'] as $key => $block_info) {
      $block = block_load($block_info['module'], $block_info['delta']);

      // If this block should be served by ESI, replace the module and delta,
      // so that when block_view is invoked, the block contents are populated
      // correctly.
      if (!empty($block->esi_enabled)) {
        global $theme;
        $context->reactions['block']['blocks'][$key]['theme'] = $theme;
        $context->reactions['block']['blocks'][$key]['module'] = 'esi_block';
        $context->reactions['block']['blocks'][$key]['delta'] = esi_block__new_delta($block->module, $block->delta);
      }
    }
  }
}