Regions are the areas on your site where you can place blocks, as we did in Chapter 2 and in other places throughout this book. Drupal provides five regions by default:

You can change this list of regions for your theme in its .info file. Here is an example that creates a new region, Ads, and also excludes some of the defaults, such as Header, by not defining them:

regions[ads] = Ads regions[right] = Right sidebar regions[content] = Content regions[footer] = Footer

By defining just these regions in the theme, site administrators are limited in where they may place blocks on the block administration page for this theme. There will be no Header or Left sidebar for them to use. This can be very powerful when you have a very specific layout and you don't want administrators putting things in the "wrong" place.

There's also a second step to displaying block regions, which is printing a variable for the region in your theme's page.tpl.php file, such as <?php print $ads; ?>. This command will print out all of the blocks that have been placed in that region. We'll delve into this more later in the "Creating a New Region" section.

If you define regions in your .info file, then Drupal will no longer use its defaults. If you define even one region, then you must explicitly define all of them that you wish to use. For example, if you add a new "Ads" region, then you need to also define the left, right, content, header, and footer regions if you want to use them as well.

Was this article helpful?

0 0

Post a comment