ARCHIVE: How to add a new Region to your Theme

Last modified: March 27, 2009 - 00:10

(This topic is covered in more detail here: http://drupal.org/node/171224)

Faced recently with the need to add a new block region that spanned the right column and the center column, I hacked my way into our theme to get results, only to find those results disappearing randomly.

Finally I searched here on the Drupal site and I was NOT rewarded with a simple solution.

An obscure comment suggested putting the regions into the theme.info file, so I played, but when I added

regions[top] = 'Page Top (over content and right)'

I had the unexpected effect of loosing all other regions that my theme needed. (making navigation very difficult) :D

I checked the database for the original base theme and ended up using the following lines in my theme.info:

regions[header] = "Header"
regions[left] = "Left sidebar"
regions[top] = 'Page Top (over content right)'
regions[right] = "Right sidebar"
regions[content] = "Content"
regions[footer] = "Footer"

I'm not certain that this is the best way, in fact I find it very non-obvious that what appears to be "adding a single entry" to the regions array invalidates all previous entries, however, barring some bright young hotshot showing me what I've done wrong, the above method works.

As you discovered, when you

mjohnq3 - March 27, 2009 - 00:20

As you discovered, when you override the Drupal default regions (sidebars, content, header and footer, etc.) you need to redefine those default regions. You haven't done anything wrong, in fact, you did exactly what is required.

I copied and paste a region

Kevander - July 12, 2009 - 22:31

I copied and paste a region above my menu. But it doesn't work.
On my frontpage is my HTML block under my menu and when I visit all my links then it is OK.

 
 

Drupal is a registered trademark of Dries Buytaert.