You are here

function _context_ui_block_rehash in Context 6.2

A helper function to rebuild the 'block cache' for a number of given themes.

This is needed because _block_rehash() uses the global $theme_key to know which theme's block cache to 'rehash'. This function has the potential to go horribly wrong, and leave the user looking at some very random theme.

Drupal maintains a 'block cache' of all the blocks from different modules in the 'blocks' table, but it doesn't get rebuilt very often, and it doesn't get rebuilt for any themes except the active one (in that page request).

Parameters

$themes: An array of theme names to rebuild the 'block cache' for.

1 call to _context_ui_block_rehash()
_context_ui_get_blocks in context_ui/context_ui.admin.inc
Helper function to generate a list of blocks from a specified region. If provided a context object, will generate a full list of blocks for that region distinguishing between system blocks and context-provided blocks.

File

context_ui/context_ui.admin.inc, line 1078

Code

function _context_ui_block_rehash($themes) {
  global $theme_key;

  // Store the current theme key for later:
  $previous_theme_key = $theme_key;
  foreach ($themes as $theme) {

    // Temporarily set the given theme as the active theme:
    $theme_key = $theme;

    // Rebuild the 'block cache' for the given theme.
    _block_rehash();
  }

  // Restore the previously set theme:
  $theme_key = $previous_theme_key;
}