Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Trying to get the multiblock module working with multiple instances for my custom modules, i found out that the $edit parameter came empty for the hook_block_view hook, so, looking at your code, i found the line 106 of the multiblock.module file is not passing the $edit parameter.
Is this on purpose ? i had to add the parameter to make the hook_block_view to work with different configs for the different instances.
Old code:
//... line 106
if ($op == 'save') {
$block = module_invoke($block_info->module, 'block_'. $op, $block_info->orig_delta, $edit);
}
else {
$block = module_invoke($block_info->module, 'block_'. $op, $block_info->orig_delta);
}
//...
New Code
$block = module_invoke($block_info->module, 'block_'. $op, $block_info->orig_delta, $edit); //Adding the $edit parameter becomes the if sentence obsolete
Hope it helps
Comment | File | Size | Author |
---|---|---|---|
#5 | fix_config_per_instance-1370966-5.patch | 556 bytes | pablitt |
Comments
Comment #1
NancyDruHook_block_view does not get a $edit value, only hook_block_save does.
Comment #2
pablitt CreditAttribution: pablitt commentedOk, my bad, so how do you know witch Id to use to get variables in hook_block_view ?
Comment #3
NancyDruhttp://drupal.org/node/353565
Comment #4
pablitt CreditAttribution: pablitt commentedYeah, i read that, and that's where i think it's confusing, "Once you do this, the instances you create will get the block instance ID passed in the $edit variable for the view, configure, and save $ops.", that's ok for D6, but in 7 you can't use hook_block anymore.
Maybe i'm missing something...
Comment #5
pablitt CreditAttribution: pablitt commentedHere is a more cleaner fix for the same issue. With this fix, you will need to add to your
hooks an extra parameter for the delta_delta block, for example:
hook_block_save() should work as usual
Hope it helps,
cheers.
Comment #6
FDIM CreditAttribution: FDIM commentedI've just hit this issue, any chance to get this module patched?
I reviewed the code and this only effects drupal 7 version, it is actually correct on 6th.
It actually sends additional data only when saving, it has to send it to all ( view,configure and save )
It is an easy fix, modification of module is not an option for production server.
Suggested fix:
Instead of:
Comment #7
jennypanighetti CreditAttribution: jennypanighetti commentedI'm about to need this module in a production site. Really saddened to see this module is not yet production-worthy.
FDIM: Did your code snippet fix the problem? Can you make it into a patch?
Comment #8
MJD CreditAttribution: MJD commentedJust trying out this module...
my problem is that it would appear I can't edit an instance but can delete one from here
admin/structure/block/instances
can someone confirm this is the fault
Comment #9
Renee S CreditAttribution: Renee S commentedThe fix in #5 was what was needed to get it working for us. Thanks.
Maintainers: It would be great if you could take a look at this, it's a serious production-blocking bug and it's been sitting here for a year and a half.
Comment #10
Renee S CreditAttribution: Renee S commentedFlipping this to RTBC.
For reference when working with multiblock module and the patch in #5:
- Add $multi_id = NULL parameter to hook_block_configure() and hook_block_view()
- hook_block_save() works as is. Get the block_id with $edit['multiblock_delta']['#value'], not the $multi_id variable as suggested on the Drupal Multiblock page.
Comment #12
intrafusionI can confirm this patch works and is the only thing holding this module up.
Can we get this committed and released or is the module dead?
Happy to take over as co-maintainer to get this module moving.
Comment #13
ITWest-jg CreditAttribution: ITWest-jg commentedFound same issues. Can we get this patched please? I think the patch (#5) needs to update the README.txt file with some infos on what is passed to each of the hooks...
Comment #14
intrafusionI believe this issue will have been handled by #2112485: Provide information about multiblock to all other modules' hook_block_...() hooks, not just save
Marking as fixed