function multiblock_call_block in MultiBlock 7
Same name and namespace in other branches
- 5 multiblock.module \multiblock_call_block()
- 6 multiblock.module \multiblock_call_block()
Dispatch a hook_block call to its respective module. Paramater $delta is the new multiblock delta that we're using and $op is the op we are dispatching.
@edit Information originally passed to multiblock's corresponding hook. For example, a call to multiblock_block_view($delta, $edit) will result in a call to multiblock_call_block($delta, 'view', $edit). Note that Drupal's API does not call for $edit parameters for hook_node_view() or hook_node_configure(), but multiblock does.
Parameters
$delta: The delta of the multiblock block, which is different from the delta of the block in the original module
$op: Can be configure, view, save...
Return value
Information returned by the corresponding module_invoke() call.
3 calls to multiblock_call_block()
- multiblock_block_configure in ./
multiblock.module - Implements hook_block_configure().
- multiblock_block_save in ./
multiblock.module - Implements hook_block_save().
- multiblock_block_view in ./
multiblock.module - Implements hook_block_view().
File
- ./
multiblock.module, line 124 - Enhances the block API, as provided by D7 Core.
Code
function multiblock_call_block($delta, $op, $edit) {
// Get block info from multiblock_get_block() which now checks that the original module
// still exists before returning the info.
$block_info = multiblock_get_block($delta);
// Check we actually have a block to render.
if ($block_info) {
// If this block is multiblock enabled, send it the delta of the block we're using.
if ($block_info->multi_settings == 1) {
$edit['multiblock_delta'] = array(
'#type' => 'value',
'#value' => $block_info->delta,
);
}
// This will result in a call to the original module's hook_block_view(),
// hook_block_configure(), or hook_block_save() function. In cases where
// modules define multiblock-enabled blocks (that is, in their
// hook_block_info() function, they return an associative array of block
// machine names to arrays with 'mb_enabled' => TRUE for each mb-enabled
// block), these modules' hook_block_view() and hook_block_configure()
// functions will have an extra $edit = array() parameter, in which
// information about multiblock is passed. This will allow blocks to
// contain and display different configuration information per instance.
$block = module_invoke($block_info->module, 'block_' . $op, $block_info->orig_delta, $edit);
if ($op == 'view') {
if (isset($block['content']['#form_id'])) {
// Handle duplicate form IDs
$block['content']['#id'] = drupal_html_id($block['content']['#id']);
}
$block['orig_module'] = $block_info->module;
$block['orig_delta'] = $block_info->orig_delta;
}
return $block;
}
// No such multiblock, shouldn't ever happen.
return;
}