How to Create Custom Blocks in Drupal 7

Drupal divides a web page in several regions, including sidebar, footer and header, which holds blocks for a display of various content in perfect order. By default, the blocks include system help, main menu, user login, Who’s Online, search from, etc.

If the default blocks can no longer satisfy the basic requirements, creating a custom one is great for you. Follow this guide on how to create custom blocks in Drupal 7 and create custom blocks via Drupal dashboard.

Step 1: Log into Drupal with an own account and click the Structure tab. A list of items is available for Drupal structure customization, among which the Blocks is the one to be selected. That allows you to decide what will appear in the existing regions. Click Blocks and enter a drag & drop interface for blocks management.

Drupal Structure Blocks

Step 2: Click the “Add block” link and here you come to a new block editing page. Type the block title and that is the name of this block shown to visitors. Describe this new block briefly in Block Description field, which is displayed on the drag & drop interface you’ve visited just now. It helps you recognize a block at a glance. The Block Body is where to enter the HTML code for this block and something else as needed.

Block Basic Information

Step 3: Move to Region Settings and determine where to display this newly created block on your website. Expand the drop-down list and select a region to hold this block. The “Sidebar first” is selected in this guide.

Region Settings

Step 4: The Visibility settings mode includes four options to customize the display of this block. The Pages option requires you to make a decision where to show this new block, specific to a page. The Content Types option determines which content types should be used to hold this block. The Roles option includes three user roles and that allows you to make a decision who can view this block. The Users option enables customization for each user.

Make a decision on how to show the block for specific pages, specific content types and specific roles. And then, set the user permission to customize the visibility of this block. Click “Save Block” to confirm all settings.

Visibility Settings

Manage Blocks

Having all custom blocks created, explore more possibilities via Blocks Administration Page. Go to Structure > Blocks and access to the drag & drop blocks management interface. The link “Demonstrate block regions (Bartik)” redirects you to the distribution diagram for all regions as the following screenshot. That helps you know fairly well where each region is so as to display all blocks in proper positions.

Block Region Demonstration

If you come round to the position of certain blocks, you are allowed to make some changes in anytime on the Blocks Administration Page. A list of regions shown on the interface and each includes none or several blocks. You can drag and drop certain blocks to simply reorder them. If there is a need to assign a block to other region, expand the drop-down list next to this block and select any region as planned. The block is automatically assigned to the target region.

Assign Block to Other Region

Scroll down to the bottom of this page. The Disabled region includes an array of blocks that are not shown on the web page. Expand the drop-down list for a disabled block and select a region to hold this block. Whereas if there is a need to disable an active block, select “None” from the drop-down list. By the way, the “configure” link redirects you to the edit page for a block.

Recover Disabled Blocks