Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
You know that blocks are containers for content that can appear in specific block regions of your Drupal layout. Those block regions are determined by the theme. None of that has changed in Drupal 7. What has changed is that blocks are much more flexible than they were before. Virtually all content is now blockified so to speak, so it can move around the page much more freely. Also the default theme Bartik, which you see here, has a lot more block regions than Drupal 6's good old Garland and the interface for administrating blocks is easier to use.
I will show this first by taking a look at the block interface in Drupal 7 but I will also go and take a look little bit in Drupal 6. In Drupal 7 you get there by clicking Structure and then Blocks. This page is very much like the Block Administration page in Drupal 6. I will go there by going to Drupal 6, Administer, Site building, and Blocks. There is one difference. In Drupal 6 you see the block regions on the Block Administration page, Header here, Right sidebar, Left sidebar and so forth. Partly that's possibly because Drupal 6 didn't really plan to have as many block regions as people have started using.
Let's take a look at it in Drupal 7. You don't see the block regions on the Block Administration page. There's a good reason for that because when you're administering by default, you not seeing the theme itself. We are working on the Bartik theme as you can see from this tab over here, but our administrative overlay is the Seven theme. So to show the block regions we click right here, Demonstrate block regions. Now we see them in the theme itself and as you can see there's a lot more. Instead of the five that were originally in Garland, there are 15 in Bartik.
Now the fact that Bartik has 15 block regions isn't really that unusual. Drupal 6 had themes which had 15 block regions. In fact one of the most popular ones Acquia Marina had 15 and some of them had even more, but what is interesting is that this theme is included in core, so suddenly people were just downloading Drupal without any contributed themes are going to have a lot more flexibility in the way that they design their pages. To leave this block region demonstration you just click up here. Now let's take a look at a couple of new blocks that didn't exist in Drupal 6, One of them is System help and another one is Main page content. These were things that just showed up in Drupal 6 and you couldn't change where they were.
If we go into Drupal 6 and I'll just go back to our front page, if a Help message were to appear, it would show up here at the top, sort of right above the content and the content itself would always be in this middle area here in the Content block region. Well in Drupal 7 you can completely change that. In fact let's go back and do that. I will close out this. Here we have a little bit of content that's in the Content region. I will go back up to Structure and Blocks and move the Main page content, let's say to the right-hand sidebar which is called Sidebar second, scroll to the bottom and save, close it out, there. Now we could actually start having our content here and if we wanted we could for example put a big picture here or some feeds or whatever.
I'm going to switch it back so it looks the way that we expect. We go up to Structure and Blocks once again, scroll down and I put the content back into the Content area and save and it's back to normal. Let's take a look at the individual block controls. I will scroll down to one, let's just say Navigation, which is the same between Drupal 6 and Drupal 7 and click configure. I will do the same in Drupal 6. We go to Administer, Site building, Blocks, scroll down to Navigation and configure.
The first thing you will notice in Drupal 7 is that it's a lot more compact. Again that's because of these vertical tabs which you know from creating content. The Block title is the same in both but then we have this Region Settings, which doesn't exist in Drupal 6. This is really nice because what happened in Drupal 6 is you'd create the block and then you'd have to go back to the Administration page in order to decide where to put it, but a lot of times when you create a block you know where it's going to go. So we just go ahead and put it there from this page. Now we only have two themes enabled, Bartik and Seven. If we had more they would all show up here and you'd be able to say "okay when it's on this theme, I want it in this region" and so forth for all of the different themes.
Going down further, we have our visibility settings. These were actually pretty complicated in Drupal 6. You see we have user visibility and a set a controls, role specific visibility, page, and it took a little bit of figuring out. In Drupal 7 we have all of those in vertical tabs, so it's much cleaner, and then we have an additional one, Content types. You could actually decide which nodes you want to display this block. So let's say we have our Vacation package type, which we created here. This is a Content type and we wanted this block only to show up when we were shown the Vacation package. We just clicked that and it just wouldn't appear in the other ones.
We'll just say Save block and get out of that screen. Like so many changes in Drupal 7, the changes to the block system aren't earth shattering. Rather they are set of well considered incremental improvements backed by some pretty ingenious programming. I really love the flexibility that blocks have got in Drupal 7. I think that together with the changes in the theming system, we are going to see some really interesting layouts in future Drupal 7 sites.
Get unlimited access to all courses for just $25/month.Become a member