Drupal 7 Multiblock Module

By adam
Fri, 2014-05-30 06:26
Daily Dose of Drupal Episode #154

Share with Others

In this episode, we are taking a looksie at the Drupal 7 Multiblock module. This gem, allows you to create separate instances of your site blocks. This is a helpful tool when you want to display blocks in different regions of your site without having to create separate entities or blocks. Note, at this time of recording we are using the Drupal 7.x-1.1 version. Even though this isn't a recommend release, it seems to function properly.

Hey everybody and welcome to Episode 154 of the Daily Dose of Drupal, I am Adam Learing coming to you … a couple of thing before we get started. Today we are going to be covering the Multi-Block Module, pretty easy module but actually kind of a helpful module especially if you are beginner use and not as familiar or comfortable with using code, nice little module that extends some other Drupal Block functionality.
Before we jump in to that module I just want to quickly mention a few things, head over to codekarate.com and make sure to sign up for our newsletter there sending out typically once a month a couple of times … maybe twice a month updates on either our post or happenings in the Drupal community, stuff like that, nothing too crazy but just a nice where you stay informed.

Also if you’re on social networks especially Twitter make sure to head over and follow us both. You can follow myself @adamlearing on Twitter or you can follow Shane @smthomas3. Either are be good, Shane has probably touched better since he got tweets a lot more often than me. Anyway; anything else about tightening up … so anyway let’s get started with the Multi-Block Module, again the Multi-Block Module like I said is an extension of the block from and Drupal Core but as the ability for you to use the same Block or Multi-Block multiple places on your site and I’ll show you a couple used cases for that here shortly.

One thing to note is there is not a recommended release for the Multi-Block for Drupal 7 which is what I’ll be using but the 7.11 version seems to work just fine so go ahead and you can download that on the drupal.org site. So once you get that installed we can head over to our site and we’ll enable our Multi-Block Module, turn that on. No other modules or anything else required for this so it’s all you need to do.

So once you get it turned on head over to Structured Blocks Instances. If you don’t have this admin menu installed which is what you’re seeing in my screen, you simply go to structure, click Blocks and then there’ll be a tab here on the top called instances. So let’s go ahead and click that. So in here you can do a couple of things; you give it a title and then you select the block that you want to clone essentially. So in this sense first you can actually switch back and head to creating a block so I can show you how this works.

So we’re just going to add a Block and we’re going to give it a simple name here and then we’re going to set this in our sidebar first or our left sidebar or we’re just going to list it on every page. So once you save that … simple, this is obviously basic Drupal stuff here but just to show you how this Block will appear by default so if you actually go look at our site here you’ll see it’s right here on the corner, it say Welcome to Code Karate. So that’s the block that we just created but now let’s say that we actually want that exact same block also to appear in the footer. So that’s where this Multi-Block Module comes in and this instance thing we’re speaking of.

So if we go to the Structure Blocks click instances, let’s give it a title … I recommend using a separate title so you can tell the difference, this is going to be “Hello World 2” and then select the block that you want to multi-block or clone. So there’s the Hello World block I just created, save this instance. Okay so we have our instance created, we have our Hello World Block so if we go to our [inaudible - 0:04:37.0] or back to our block layouts we can see that now I can see a Hello World 2 here which is an indirect clone of this Hello World right here.

So I’m just going to step this Hello World 2 in my footer first column and go ahead and save that and then you’ll see here once the page saves, loads, you can see I now have a second block that is the direct clone of my first block. So Hello currently here and Hello currently there. One thing to note is actually if I configure and change this block, say I want to add some exclamation points and save it it is a direct clone of the block so wherever I change in the master block will be reflect automatically in the second block.

So you know how to change it in two places and they’re tied together. Obviously in this case that … the case I showed you is not as useful as some other cases. One very interesting one would be using a Newsletter Block whether you’re using Mail Chimp or A Webber or your choice of them. They typically come with one block so say you want to have it on your sign-up form on your left hand side block on the front page but on every other page you want to have a newsletter block also appearing in the footer or the multi-block module is going to allow you to do that. You can set different feasibility rules or you can also just set it in different region based on the visibility rules or pages.
So that’s kind of a really good use case and one that we’ve used in the past for that. Of course there are other options to pull this off. You could use Panels … Drupal Panels, a little bit … these videos are now on Code Karate, I recommend you would check those up first but like I said the Multi-Block Module is a really simple no code needed option to display Multiple Blocks in different areas without having to duplicate the exact same content.

Alright guys before we head out I just want to again just mention codekarate.com hosting a bunch of videos there, obviously 154 at this point as well as some other blog post, check out the newsletter, I appreciate anybody signing up, we really appreciate the commitment there and also we’ve been saying this and it is coming and we are working very … we’re getting very close to producing our e-book on The Five Secrets to Becoming a Drupal 7 Ninja. So make sure to keep that in mind, signing up the newsletter will get you first depths at that as well. Alright guys thanks a lot and we’ll talk to you later. Bye.