Skip to content

Instantly share code, notes, and snippets.

@splatio
Last active December 21, 2015 00:59
Show Gist options
  • Save splatio/6224428 to your computer and use it in GitHub Desktop.
Save splatio/6224428 to your computer and use it in GitHub Desktop.
diff --git a/template.php b/template.php
index 86e8d7a..37b4c60 100644
--- a/template.php
+++ b/template.php
@@ -623,13 +623,18 @@ function omega_template_process_html_override(&$variables) {
*/
function omega_block_list_alter(&$blocks) {
if (omega_extension_enabled('layouts') && $layout = omega_layout()) {
- // In case we are currently serving a Omega layout we have to make sure that
- // we don't process blocks that will never be shown because the active layout
- // does not even have a region for them.
- foreach ($blocks as $id => $block) {
- if (!array_key_exists($block->region, $layout['info']['regions'])) {
- unset($blocks[$id]);
+ // CTools statically caches it's block list, if this is invoked from CTools the
+ // static value will be NULL, otherwise it has already run and will be an array
+ // of blocks or use the default value of FALSE.
+ $ctools_blocks = &drupal_static('_ctools_block_load_blocks', FALSE);
+ if ($ctools_blocks !== NULL) {
+ // In case we are currently serving a Omega layout we have to make sure that
+ // we don't process blocks that will never be shown because the active layout
+ // does not even have a region for them.
+ foreach ($blocks as $id => $block) {
+ if (!array_key_exists($block->region, $layout['info']['regions'])) {
+ unset($blocks[$id]);
+ }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment