Skip to content

Instantly share code, notes, and snippets.

@kevin-coyle
Created January 21, 2014 14:03
Show Gist options
  • Save kevin-coyle/8540638 to your computer and use it in GitHub Desktop.
Save kevin-coyle/8540638 to your computer and use it in GitHub Desktop.
Modified from http://dcycleproject.org/blog/32/disabling-blocks A simple helper function to disable blocks programatically. Useful for deployment modules.
/**
* Helper Function to disable blocks
* Modified from http://dcycleproject.org/blog/32/disabling-blocks
* @param string $theme The name of the theme you'd like the block to be disabled on
* @param array $blocks Array of blocks. Module => Block name
*/
function disable_block($theme, $blocks) {
foreach ($blocks as $module => $delta) {
$num_updated = db_update('block') // Table name no longer needs {}
->fields(array(
'region' => '-1',
))
->condition('module', $module, '=')
->condition('delta', $delta, '=')
->condition('theme', $theme, '=')
->execute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment