![]() |
Services | Software | Partners | Articles | Contact |
How To Create An Announcement / Newsflash BlockWe 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() {Then, in page.tpl.php, add this snippet above the breadcrumbs (or anywhere else you want). <?php if ($content_top) : ?> 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 ... |



i can't find any region
i can't find any region called 'content top' in the administer -> blocks page. after applying ur code in both the files. Plz help
Comma trouble ?
I'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 :
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'),
);
}
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...)
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') // There is NO comma at the end of the last region defined because we are closing the array //
);
}
Valid syntax
Actually 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 consulting
Which Drupal version, what themes?
"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.
Create a new one
If your theme is in themes/bluemarine, then create a new file called template.php, and put this stuff in it.
--
2bits.com