Working With Blocks

Custom Blocks

You can make a block contain just about anything you'd like. Sample blocks include:

  • About the company.
  • Contact information.
  • Accolades.

To add your custom blocks to your site, complete the following instructions:

  1. Using the admin dashboard, navigate to Structure > Blocks.
  2. Click on the link labelled Add block.
  3. Enter a Block description (used in the admin section only) and the text that you want visitors to read (this goes into the Block body).
  4. Scroll to the fieldset labelled Region settings. Place your block into one of the regions on your site. The available regions will vary from site to site.
  5. Scroll to the bottom of the configuration screen and click Save block.

Your new block should now appear on every page. Close the overlay and navigate to your contact form to check your work.

Conditional Blocks

Sometimes you only want blocks to appear on some pages. For example: adding your phone number and address to the contact form or accolades about your photography work to appear only on the photography pages. This trick relies on the path for your pages, so you will need to be careful when assigning URLs to make sure they contain the right words for the block to appear. (You can also use pathauto to make the URLs happen automagically.)

The block you want to modify should already be created.

  1. Using the admin dashboard, navigate to Structure > Blocks.
  2. Locate the block you want to alter and click the link labelled configure.
  3. Scroll to the fieldset labelled Region settings and choose the region name for the theme you are working with. For example: in Bartik Sidebar first.
  4. Scroll to Visibility settings. Click on the vertical tab for Pages. Enable the option for Only the listed pages. In the large text area below the option you just enabled, enter the Drupal paths for the pages you want the block to appear on. For example: contact. Read the inline instructions for more details about what can use used as a path.
  5. Scroll to the bottom and click Save block.

Your block should now be limited to only the paths you've specified. Close the overlay and navigate to your contact form to check your work.

Want More Tutorials?

Are you interested in getting even more tutorials sent to your inbox? Sign up for our incredibly popular tips mailing list and get a free tutorial every month. You may even win a coupon for a free e-book (include your whole name if you want to win stuff).

For a limited time we'll even send you a bonus tips sheet The Top Ten Mistakes People Make when Theming Drupal when you sign up for the list.