function rb_block_action_place_block in Rules Bonus Pack 7
The 'rb_block_action_place_block' action.
File
- ./
rb_block.rules.inc, line 97 - Rules actions to more or disable a Drupal block. Plus some helper functions.
Code
function rb_block_action_place_block($block, $region, $weight) {
// Compare the region against the currently active theme – we only want to
// insert blocks if the region matches this theme.
global $theme;
$region_info = explode('-', $region);
if ($region_info[0] != $theme) {
return;
}
else {
// Ok, the theme is right. Change the $region variable to only contain the
// actual region name – not the theme name.
$region = $region_info[1];
}
// Get block data.
$block_info = explode('||', $block);
$new_block = block_load($block_info[0], $block_info[1]);
// Set the modified values for the block. Also assure that the block is set as
// active.
$new_block->region = $region;
$new_block->weight = $weight;
$new_block->theme = $theme;
$new_block->status = 1;
// Set the block as a Drupal static, to allow it to be called from outside
// this action (namely from hook_block_list_alter).
$blocks =& drupal_static('rb_block_blocks');
$blocks[$new_block->bid] = $new_block;
}