We needed to have a newsflash announcement at the top of certain pages on a site. Here is a quick way of doing this with minimal theme code.
In order to do this, we decided to use the new "regions" feature for Drupal 4.7 blocks.
To do this, edit the template.php file in your theme directory. Add the following hook to it:
function yourtheme_regions() {
return array(
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'content_top' => t('content top'),
'content' => t('content'),
'header' => t('header'),
'footer' => t('footer'),
);
}
Then, in page.tpl.php, add this snippet above the breadcrumbs (or anywhere else you want).
<?php if ($content_top) : ?>
<div align="center"><?php print $content_top ?></div>
<?php endif; ?>
You now have a region called 'content top' in the administer -> blocks page. In it you can put any text you want, and restrict visibility to certain areas of the site using the standard waya of doing so for blocks.
One can get more creative and write a custom module that would publish blocks on certain dates, and such ...
Comments
Visitor (not verified)
Which Drupal version, what themes?
Tue, 2006/08/08 - 04:08"edit the template.php file in your theme directory"
Can't find that file anywhere. Where is it?
Not anywhere in 4.7 or the 4 themes that comes with it.
Khalid
Create a new one
Tue, 2006/08/08 - 09:47If your theme is in themes/bluemarine, then create a new file called template.php, and put this stuff in it.
--
2bits -- Drupal and Backdrop CMS consulting
Visitor (not verified)
Comma trouble ?
Tue, 2006/12/05 - 09:37I'm in search for some good documentation on the web about drupal themes "how-to" and i have found your website interresting :
You have written in your example :
I'm not sure if i'm right but there is no 'comma' at the end of an array (I'm not a PHP expert like you are...)
Khalid
Valid syntax
Tue, 2006/12/05 - 09:40Actually PHP allows both with and without an end comma.
It is very convenient to be able to add lines after the last one, or rearrange them without the need to remember to remove the comma at the end.
--
2bits -- Drupal and Backdrop CMS consulting
uday (not verified)
i can't find any region
Tue, 2011/01/04 - 02:27i can't find any region called 'content top' in the administer -> blocks page. after applying ur code in both the files. Plz help