Unlimited WordPress themes, graphics, videos & courses! Unlimited asset downloads! From $16.50/m
by
Lessons:33Length:3.7 hours
Drupal 8 1
  • Overview
  • Transcript

3.4 Understanding Blocks

In the previous lesson, we glossed over the concept of blocks. Let's dig a little deeper and get a feel for what blocks are and how they work with the theme of your site.

3.4 Understanding Blocks

In the previous lesson, we looked a little bit into the world of blocks and the sidebar over here but we did it within the context of creating a view. Now that was just a brief introduction, let's take a little bit closer look into this whole world of blocks. So let's go back to Structure and let's go to Block layout. And let's take a little bit closer look at this. Now what you are going to notice as I mentioned before, is that the block layout is specific to the theme that you are using. And we're gonna talk a little bit more about themes and appearance in an upcoming lesson. But just, for now, note that when I come in here and look at the block layout, right now my active theme is Bartik, so that is the one that I see. But I can go ahead and take a look at any of the other installed and configured themes that I have within Drupal. So as you can see, I can take a look at Seven, as well. And I can take a look at the block layout for that one as well. So, let's go back to Bartik since that one is currently active. And this may be a little confusing as to what all of these things mean. What does header mean? Where's the primary menu? Where's highlighted? Where is sidebar first? Where is sidebar second? Well, it's actually quite easy to see in that when you take a look at the block layout for any particular theme all of them, at least to my knowledge that I have seen so far, will provide to you a bit of a map to show you where exactly these blocks are located. Because you may have some of them or maybe not all of them for all of the different themes, they are very theme specific. And the way that you see where all of these things are located is by coming down to this link where it says demonstrate block regions for that particular theme. So let's click on that. And now you're gonna be taken to a view where it's going to show you, in these highlighted bars, where all of these blocks are located. So, it's a very useful road map. So, I can see the secondary menus at the very top, then I have a header and then I have a primary menu. And this is where that main navigation area is. Then I have a highlighted section in a featured top, then I have my breadcrumb. And I have my sidebars and content as well as all of these other blocks. Now, these are not always going to all be the same for all themes. So I highly recommend that whenever you are deciding on using a specific theme to take a look at the layout. And make sure it is going to follow what you are needing for your particular site design when it comes to block. So it's just kind of something to get in the habit of. Whenever you start to play around with different themes it would definitely behoove you to take a look at the block region layout. So we can exit the block region demonstration. And now we can have a little bit closer look into the layout of all of these regions, as well as the blocks within them. Now I am not limited to put these different blocks in these different regions. I can put them anywhere that I want. But once again a little bit of a caveat there are certain blocks that just make sense to be in certain regions. For instance, it probably makes sense for me to put the breadcrumb block in the breadcrumb region that just kind of goes without saying, as well as maybe the site branding in the header or maybe the main navigation in the primary menu. But like I said before, you could pretty much put them anywhere that you want. But it's just something that makes a little bit more sense and it will format and display these blocks a little bit more appropriately if they're put in the correct areas. But you're more than welcome to move things around a little bit and there are a couple different ways to do that. So if we go back to the layout here and we take a look at the regions, we see that we have sidebar first, which is where we removed our toolbar from as well as added in our latest or newest articles. But we also have this second sidebar over here. So we can begin to play with this layout a little bit. Maybe for my particular site design, it makes more sense to leave the newest articles in the sidebar first but maybe move the search bar over to the side bar second so how can we do that. Well, we could simply come over here to the search block and we could change the drop down to go to sidebar second. Or we could just as easily click this and drag it down to the sidebar second, just like that. But now, do remember that since I made that modification, I do have to come down to the bottom of the screen and hit Save Blocks. So now once I've done that I can go back to my site and now I will see that I have my newest articles here. I have my content in the center and my search box is over on the right. So once again, all of this really depends on the layout of your site and what you are looking to do with respect to the theme that you currently have active.

Back to the top