Drupal: Define a new block area in your theme

July 9, 2009 · Posted in Content Management System · Comment 

I really struggled to get info on this one, and drupal.org’s search keeps turning off due to being overloaded. I find the Drupal template or theme I am using generally does not have blocks where I want them for inserting ad slots or just block elements.

I am using Drupal 6 and wanted to define a new block area at the top of the page for banner ads, how is it done?

1. In the theme folder in the theme definition file my_theme_name.info add the following (usually at sites/all/themes/theme_name/my_theme_name.info):

regions[banner_top] = banner top

2. In the file page.tpl.php (in the same folder most likely sites/all/themes/theme_name/):

<?php print $banner_top; ?>

3. And this is the thing that catches everyone, in the admin area:

Go to admin/settings/performance and at the bottom click on the “Clear cached data” button.

If you now navigate to admin/build/block and you should see your new block highted. You can edit page.tpl.php to get your positioning, and there is no need to flush the cache again.