Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
One way that you can change the look and function of your Drupal site without changing the theme is to use a feature called Blocks. Blocks let you put text or graphics, or even dynamic content at various points in the pages. For example in the left column, right column, top, or bottom. To use Blocks, first go to Administer and then Blocks. Here you have a list of various blocks, including those that are built into Drupal and are turned on by default. In this case, in the Left sidebar we see the User login and the Navigation Bar.
The User login only shows up when somebody is logged out. So we'll log out here and see what that looks like, here is the User login and we are going to login again. Let's go back to Blocks now. As you go down, you see that the blocks are divided into various zones, the Left sidebar, Right sidebar, Content, Header, Footer. And as you look around the page, you see that these are graphically shown, Header up top, Left sidebar, Right sidebar, and so forth. At the bottom of the list of blocks are those that are not showing up on the page at all. You can move these into any of the above areas by either clicking on this arrow symbol and dragging it into the area. I am going to drag that back now or by grabbing this drop down menu and choosing the area where you want that block to appear.
Whenever you make a change, even if you drag it back to its original place there is a note that says that the changes will not be saved until you click on Save Blocks. The block layout on a page is specific to the theme, let's go to administer themes and see how that works, Administer and Themes. Right now we only have one theme enabled - the Garland theme. But let's say we also have Blue Marine available to us, we'll enable that and click on Save Configuration and then go back to Administer and Blocks. Now you'll notice we have a choice, Garland and Blue Marine up here. If we make a change in Garland, let's say we disable the Powered by Drupal badge that appears at the bottom of the screen, by dragging it down here.
Scroll to the bottom, click Save Blocks, and then we switch to Blue Marine. Aha! Powered by Drupal is still showing up in that footer. Let's go back to Garland and put it back. So remember, if you make a change in where blocks appear, you have to make that change to whatever theme is going to be active on your site. I am going to go down and just return this to the footer and click on Save Blocks. There are three types of blocks, which you can see in this list here. The first kind comes built-in automatically with Drupal. We already mentioned these - the User login block, Navigation block, the Powered by Drupal block, which you can see at the bottom of the page by default, is the one right down here.
A second kind of block appears only when it's installed by a module, let's go ahead and do that. We'll go back up to Administer and Modules and then turn on the blog Module. As always, we go down to the bottom of the page, click on Save configuration and then we'll go back to Administer and Blocks. As we scroll down, we'll notice a new entry in this list, Recent blog posts. If we drag that up to the right hand side bar, then whenever somebody on the site has added a blog post that will appear in the right hang column. We don't have to do that now, so we'll just leave it at none and save our blocks.
The third kind of block that appears in this list is that which you create explicitly by clicking on Add Block. I'll give you an example of this by going to my own website, savemyhomebook.com. Up in the left hand corner, we have a custom made block because I didn't like the way that it just showed, Admin and then there was a separate Logout link. I wanted to bring it all together into a one link. So I created this using some PHP code, so it says Logout Admin. This is a custom block out here, and we could actually go and take a look at the code to see how that works. By the way I got that code off of the drupal.org website, in the Code Snippet section, but let's go back to our site for now.
If we want to add such a block, we would click on Add Block. The block description we'll call Promotions, the blog title is also Promotions and in the block body we'll say, Buy two houses, get one free. Now let's continue on and take a look at all the options you have when you add a block. First of all, as when you add content you can choose the input format that you use. We'll just use filtered HTML, since Plain Text works just fine there. You also can choose what users will see this block and on what pages that block will be seen. You can choose specific roles that will see that block. So for example, it might be a block that helps people edit pages, but you only want people who are able to edit pages to see that block.
Well of course you could check or uncheck the roles that are appropriate. You can change whether or not users can choose whether to see that block or not. So for example, you could say they cannot control weather they see this block. That will always show the block, and they won't have any choice on it. If you say, show it by default but let them hide it or hide it by default and let them show it, then they can change that by going to their user page and change it in their profile with check boxes. Finally, you could decide on what pages you want that block to appear. For example, you might want a block to appear on every internal page but not on the homepage. In which case you would fill out the appropriate fields here and list the pages that you didn't want it to appear on here, including PHP code. We are going to have it show on every page, so we'll say Save Block. Now we look down our list of blocks and we see under disabled, we have our new block called Promotions. Whenever you create a new block, it always starts out as disabled that is, it's not automatically put on your page. We want that to be, let's say in the Right Hand column. So we'll do that and go back down to the bottom and click on Save; and there it is, it now shows up in the Right Hand Column.
Let's go back to homepage to see exactly how that looks. Tada! We now have our custom made block in the right hand column and nothing else on the page has changed. Blocks are one of Drupal's most powerful features, especially if you use them to show dynamic content such as the latest comment or blog post. Like many powerful features, however, it's easy to overuse them and make your site hard to navigate by throwing every block on to the page, but judicious use of blocks, can really improve ease at navigation and improve user engagement.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.