Skip to content

Instantly share code, notes, and snippets.

@crittermike
Created June 2, 2017 18:14
Show Gist options
  • Save crittermike/bf25971bd9d087efb9747b140ff5303e to your computer and use it in GitHub Desktop.
Save crittermike/bf25971bd9d087efb9747b140ff5303e to your computer and use it in GitHub Desktop.
(Drupal 7) List blocks being rendered by the Context module into a given region
<?php
// Grab an instance of the "Block Reaction" plugin.
$context_reaction = context_get_plugin('reaction', 'block');
// Run the block_list() function to find the blocks being rendered
// into the region you specify.
$context_blocks = $context_reaction->block_list('REGIONNAME');
// Now make sure that we reset the static cache for the block list in case
// Context isn't done adding blocks to the region for any reason.
drupal_static('context_reaction_block_list', NULL, TRUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment