[drupal-devel]
Theme system changes: theme regions, updates required
Dries Buytaert
dries at buytaert.net
Mon Aug 22 07:10:14 UTC 2005
Hello world,
last week I committed Nedjo Rogers' theme region patch to HEAD. This
means Drupal 4.7 sites can have "multiple block regions" and that
site administrators can put blocks in other regions than the
conventional left or the right sidebar. To take advantage of this
theme writers have to define additional regions in their theme. Even
if you only wish to support the left and right sidebar, some minimal
changes are needed. That is, all themes need minimal updates! This
e-mail is meant to get you up to speed with the changes so we can
update our themes and theme engines in a timely manner.
The core themes, and core theme engines have been updated by Nedjo,
but other (contributed) theme engines like XTemplate and Smarty still
need to be updated! Moreover, a new 'regions' hook has been
introduced. PHP themes need to add a mytheme_regions() function to
their .theme files, while PHPTemplate-based themes need to implement
a new "header" region (typically, below the title banner). Nedjo
provided details in "Converting 4.6 themes to HEAD", http://
drupal.org/node/25297. You could also take a look at the core themes
for inspiration or example code.
- To add new regions to a PHPTemplate-based theme, simply declare
the region(s) in a mytheme_regions() function, e.g.,
<?php
function mytheme_regions() {
return array(
'myregion' => t('my region')
);
}
?>
and then write the variables to the page, e.g., <?print
$myregion ?>. There's no need to declare and set the region-name
variable--PHPTemplate handles that. For details, see the page
"Regions in PHPTemplate", http://drupal.org/node/29139.
- To add new regions to a plain PHP theme, declare the region(s)
as above, load the blocks (as is currently done for 'left' and
'right'), and then add the result to the page output. For details,
see the new section in "Plain PHP themes" on regioning, http://
drupal.org/node/11795
An overview of the relevant documentation is given below:
* New page "Regions in themes", http://drupal.org/node/29140,
provides an overview.
* New section in "Converting 4.6 themes to HEAD", http://
drupal.org/node/25297, on minimum needed changes.
* New section in "Plain PHP themes" on regioning, http://
drupal.org/node/11795
* New page "Regions in PHPTemplate", http://drupal.org/node/29139
Let's get creative and show what can be done with this new
functionality! Nedjo has plenty of ideas for improvement, but we
wanted to evaluate these changes first.
--
Dries Buytaert :: http://www.buytaert.net/
More information about the drupal-devel
mailing list