Skip to Content

Custom regions in Drupal 6 Syndicate content

Dave Sherohman's picture

When designing the custom theme that I'm using for this and the other sherohman.org Drupal sites, I took a look at the theme I was using as my baseline example ("Basic", by Raincity Studios) and found that I wanted to place some of the site's blocks in locations which it didn't support. This proved easy to do and here's how to do it:

The really easy part

First, we need to tell the admin interface about the new region so that blocks can be placed there. This is a simple matter of going into your theme.info (remember to replace "theme" with the name of your theme) and adding the line:

regions[my_region] = My Region

There will most likely be a list of region statements already present; add this to them.

Save this change, then go to /admin/build/block and "My Region" should be available to place blocks in. If not, go to /admin/settings/performance and click the "Clear cached data", then try the Blocks screen again.

The ever-so-slightly-less easy part

Next, go into the template that you want the block to appear within - probably page.tpl.php - and find the right spot in the layout where it should be placed. At that location, add the code:

<?php if ($my_region): ?>
  <div id="my_region">
    <?php echo $my_region; ?>
  </div>
<?php endif; ?>

Save it and you're done. Your new block should appear on any new pages loaded, provided that they include the template that you placed it in.

Post new comment