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

CommentFileSizeAuthor
#5 fix_config_per_instance-1370966-5.patch556 bytespablitt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NancyDru’s picture

Status: Active » Closed (works as designed)

Hook_block_view does not get a $edit value, only hook_block_save does.

pablitt’s picture

Ok, my bad, so how do you know witch Id to use to get variables in hook_block_view ?

NancyDru’s picture

pablitt’s picture

Yeah, 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...

pablitt’s picture

Assigned: Unassigned » pablitt
Status: Closed (works as designed) » Needs review
FileSize
556 bytes

Here is a more cleaner fix for the same issue. With this fix, you will need to add to your

hook_block_view()
hook_block_configure()

hooks an extra parameter for the delta_delta block, for example:

function module_block_view($delta = '', $multi_id = NULL) { 
  $block = array(); 

  if ($delta == 'example-block') {
    $block['content'] = variable_get('example_block_block_content' . $multi_id, '');

  }

  return $block;
}

hook_block_save() should work as usual

Hope it helps,
cheers.

FDIM’s picture

I'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:

    if ($block_info->multi_settings == 1 ) {
      $edit['multiblock_delta'] = array(
        '#type' => 'value',
        '#value' => $block_info->delta,
        );
			$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);
    }

Instead of:

    if ($block_info->multi_settings == 1 ) {
      $edit['multiblock_delta'] = array(
        '#type' => 'value',
        '#value' => $block_info->delta,
        );
    }
    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);
    }
jennypanighetti’s picture

I'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?

MJD’s picture

Just 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

Renee S’s picture

Status: Reviewed & tested by the community » Needs review

The 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.

Renee S’s picture

Status: Needs review » Reviewed & tested by the community

Flipping 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.

Status: Needs review » Reviewed & tested by the community
intrafusion’s picture

Issue summary: View changes

I 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.

ITWest-jg’s picture

Found 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...

intrafusion’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.