That's a question for those who use themes provided by others and found on Drupal.org but want to add a region somewhere in the theme, most usual place would be above the content, because the CONTENT region which already exists in most themes is indeed after the content, so when you put a block in the CONTENT region it ends up after everything, one node, the tags, the comments, etc.
So what if you want to add a region to a Drupal theme?
Well here's the answer, you have to modify at the very least 2 files in your theme folder, imagine your theme is Garland:
Inside garland.info, you add the line with abovecontent (note you can choose any name) :
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[footer] = Footer
regions[abovecontent] = Above Content
and inside page.tpl.php:
<?php if ($abovecontent): ?>
<div id="abovecontent" class="region">
<?php print $abovecontent; ?>
</div>
<?php endif; ?>
Here you go, it works! Now you also can go and play with the CSS file inside the theme (usually called styles.css) and add something for the div with id abovecontent, but it is not mandatory!
edit: please note as stated in one comment below that you need to clear Drupal's cache in order to see the new region in the blocks list.




Hm. I tried this in
Hm. I tried this in Bluemarine theme, and it didn't work at all. All you sure that's all you need to do? Bluemarine is a simple, table-based theme for drupal 6. It has 4 regions, I would love to add a 5th.
Perhaps you need to refresh
Perhaps you need to refresh Drupal's cache, because for sure it does work.
Is this just for garland
Is this just for garland theme ? tried this on "Amadou" theme but it didn't work..
Not just for garland, no.
Not just for garland, no.
Just to help future people.
Just to help future people. You have to clear your Drupal Cache to make Drupal load these new regions :)
Just go to Performance part of your Drupal Admin Site and Clear Cache ;)
Thank you for helping
Thank you for helping people.
Your advice about the cache
Your advice about the cache was a piece of gold, thank you.
The suggestion about clearing
The suggestion about clearing the cache in Drupal's "Performance" admin section was the key to this. Thank you! (Why is this advice not prominently displayed on the Drupal.org theming guide???)
Note to others -- manually clearing the cache is required even if all your setting in "Performance" say that the cache isn't being used!
And how do you tell the theme
And how do you tell the theme where to put the region? - what about if you want something like a region with three columns?
I'm pretty sure you don't
I'm pretty sure you don't understand what a region is, otherwise you wouldn't ask those questions. Please refer to Drupal.org docs to better understand.
that works.. thanks.. :)
that works.. thanks.. :)
For Drupal 6. See
For Drupal 6. See http://mydrupalblog.lhmdesign.com/creating-custom-regions-drupal-6-themes
I'm already talking about
I'm already talking about Drupal 6 themes, but your article has a link to an article for drupal 5, so if people want to add a region for a drupal 5 theme they can read more info there.
I have created the view
I have created the view Headline and it should take all content with Taxonomy: Term = Headline.
I created content with just that but it doesnt show on front page. In my page-front.tpl.php. I added
<?php if ($headline): ?>
<?php print $headline ?>
<?php endif; ?>
But id just wont work. I cleared cash and disable -> enabled my theme.
In my .info file i have.
regions[headline] = Headline.
I dont understand, i have the latest drupal.
Thanks. Hope it will work.
Thanks. Hope it will work.
I have been looking for
I have been looking for something like this for so long!!! SIMPLE AND IT WORKS! THANKS!
Good post, I think this
Good post, I think this tutorial is useful!!! Thanks
Great that works also for the
Great that works also for the fusion theme. Addtional for the fusion sub-theme building, you need to copy the pate.tpl.php file from the core theme to the sub-theme folder and place the php/div lines (from above) to the needed area in it.
Post new comment