Now that we know the idea behind blocks in Drupal 7, we can create a new block. In the following tutorial we’ll show you how to create a new block in Drupal 7. We’ll also review the various settings that each block can be configured with.
To create a new block in Drupal 7:
- Log into Drupal 7 as an administrator
- In the top menu, click Structure
- Click Blocks
- Click Add block
- There are several fields that we need to fill out for this new block. We’ve outlined these values below.
Initial Block Settings
Block title Enter a title for your block. If you enable the option to show a title for your block, this is what will show. Block description The block description is used primarily to identify this particular block in your Drupal 7 admin section. If you had 20 different blocks for example, unique descriptions will help you organize and manage your blocks more efficiently. Block body The block body is the bulk of your block. For example, if you were creating a block to show social media icons, the HTML code would be entered in the Block body. Text format The Text format controls if and how your block body will be filtered. For example, there are some options that allow HTML code and others that don’t. If you select a different Text format from the drop down menu, you will see the text below it change to highlight the details of the particular format that you selected. Creating our Block How it will appear on our site Region Settings
The region settings allow you to setup where each of your blocks will appear. Beneath each listed theme, select the region to display the block in. In order to know how to choose a region, you’ll first need to know where each region is within your theme. Keep in mind too that you can change the region blocks are assigned to at any time.
Visibility settings
Pages The Pages setting allows you to restrict which pages this block will be displayed in. For example, if you had a block that showed a Google map of where your business is located, you may only what that block to show in your Contact Us page. Content types The Content types setting allows you to control which content types this block will appear with. Roles The Roles setting allows you to specify which types of users can see this block. For example, if you only want logged in users to be able to see the block, you can specify that here. Users Drupal 7 gives each user the ability to customize how your site will display for them, this includes the option to show or hide certain blocks. If you want users to be able to toggle on/off the display of this block, you’ll do that within the Users settings. - When you are finished configuring your block, click the Save block button at the bottom of the page. You should now be able to visit your site and view your new block (depending on the Region Settings as described above).