MultiBlock - Multiple instances of a block

PROBLEM

Drupal's block module is limited by the fact that a block can only have one instance. Each block has a 1:1 relationship with its region, weight, visibility (and other) settings. This means that it is impossible to have blocks in multiple regions or to have blocks that have different settings on different pages.

SOLUTION

The Multiblock module will keep track of multiple instances of blocks and dispatch to their appropriate block hooks.

Using this strategy, you would not enable any blocks that are implemented by other modules. Instead, you will go to admin/build/block/instances and create an "instance" of a block. The Multiblock module will then implement this block in its own block hook which will forward any hook_block calls to the original module's hook.

Using this method we can maintain multiple instances of blocks with different settings but the same implementation. This should not affect block-level caching.

One catch here is that the configure and save $op's for hook_block are usually implemented to save only one set of data. This means that for blocks that are unaware of Multiblock you will only be able to save CUSTOM data (this doesn't include visibility, weight, region, etc.) for one set of data.

HOW TO USE IT

Go to

admin/build/block/instances (Drupal 6)

admin/structure/block/instances (Drupal 7)

Select the type of block you want to create an instance of and type a unique title for that instance

Click "Add Instance"

Go to

admin/build/block (Drupal 6)

admin/structure/block (Drupal 7)

Enable the block instance you have just created.

DEVELOPING MULTIBLOCK-ENABLED BLOCKS

Multiblock should successfully clone any regular block created with hook_block. However, if you clone a regular block that implements a save or configure $op of hook_block, the custom block settings of one block instance will overwrite the settings of another.

To get around this, you can make a block "multiblock enabled". To do this, you have to first add an $op to your hook_block called 'mb_enabled'. It should always return the string 'mb_enabled'.

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. This will let you save and load different data to different instances based on this instance ID. It is passed in with the multiblock_delta key with the following format:

Preventing Multiblock Instances

Modules can block themselves by adding another case to their hook_block (as does Multiblock itself). If a module wants to block MB, it can implement op='mb_blocked' and return the module name as a string. For example:

Comments

You have mentioned that the $op argument should get the value 'mb_enabled' in order for to keep the different data instances for all multiblockes-enbled blocks. I am very new to drupl and I would appreciate if you could be more specific as to which part of the code I am suppose to look at and where exactly I am suppose to make those changes.

Regarding the code you posted above, still not understanding where I should include these lines. I do not have a module called Navigation, and the block Navigation that I instantiate gives no option to allow me to include code.

Which module would be one where I have to insert the code? If I do not have the Navigation Module?

First, that would be the core Menu module, and that would mean a core hack, and I strongly urge you not to do that.

You should never have to have multiple instances of the Navigation menu. Simply create another menu and add links to it as you desire. Then enable the block that will be automatically created and place it where you want.

In Drupal 7, I rarely even enable the Navigation block any more because the good stuff goes in the Main Menu.

I made a Drupal 7 module to generate a league table based on fixtures.
The league table will be a block with a settings page, where you can select the league you need.
Problem is, I will need different blocks with all their own settings.
Eg in the configuration page of the module I will select 'league 1' and then all fixtures of league 1 will be looked at and a league table will be generated.
I installed the Multiblock, and I can create multiple instances.. but under Configuration, I only see one settings page.
I want to have a settings page per instance I've created..
So I will have a settings page with league 1 for instance of module block league 1.. another one for league 2..

This is my code in my .module page

<?php/*** Implements hook_help.** Displays help and module information.** @param path* Which path of the site we're using to display help* @param arg* Array that holds the current path as returned from arg() function*/function league_table_help($path, $arg) { switch ($path) { case "admin/help#league_table": return '<p>'. t("Display league standings, please select your league under configuration") .'</p>'; break; }}

/*** Custom content function.** Set beginning and end dates, retrieve posts from database* saved in that time period.** @return* A result set of the targeted posts.*/function league_table_contents(){ //Use Database API to retrieve current posts.

I've installed multiblock module on D7 and I believed that I could create different instances of a block with different data (and not just different title). Maybe I understood wrong what is possible with multiblock ? Maybe having different data is not possible with multiblock ?

If someone can tell me if what I'm trying to do is out of subject or if I'm understanding something wrong ?

Hi all,
I've been working with multiblocks trying to get it ready for a custom blocks. What has been really hard because I wasn't able to retrieve the delta of my instance on hook_block_view() using $edit['multiblock_delta'] as the doc says to do.
However, I was able to:
enable the ability of my block to be resinstaced for mutiblock:'mb_enabled' => TRUE, // on my hoock_block_info() --> worked fine
assign a new 'subdelta' to each instance on hoock_block_configure($delta = '') :

then, save it in a different variable using our 'subdelta' on hook_block_save($delta = '', $edit = array()):$multiblock_delta = $edit['multiblock_delta']; --> worked fine, as expected.
But I've got an issue using it on hook_block_view($delta = '', $edit = array()):

And fianlly I can acces the multiinstance referent or how I called it before 'subdelta'
I think I am not breaking anything doing that on that way, if so, and someone catches it, please let me know.
With my current knowledge about Drupal (only six month using it) I'd say it was a buck on the module...

Hi, I am a newbie, and working to prep my site for public launch. I have really been frustrated by need to recreate blocks to put them in different section of various pages, and then I saw something about the Multiblock module. However, I'm in D7 and there is not a "Recommended Version" available.

- Is is safe to use the version listed under "Other" for D7?
- Has anyone had issues with it?
- Is there a plan/timeline to have a "Recommended" version for 7?

Currently i am creating a custom module with hook info and hook block configure with some additional form fields under hook configure in D7 want to make this module as multi instance so that stored variable data will be different for each instance. can some one help me with a piece of code. Any help will be highly appreciated.