drupal5.x中PHPTemplate模版引擎的Regions

PHPTemplate模版引擎是Drupal内置默认的模版引擎,区域(Regions)就象容器,Drupal的区块(block)和一些其他的内容都在区域(Regions)中显示。

在Drupal 5.x默认提供了5个区域(Regions):left 、 right 、content 、header 、footer 。在主题模版 page.tpl.php 文件可以使用$sidebar_left, $sidebar_right, $content, $header,  $footer_message这些变量来显示,如:
<?php print $header; ?>

如果想增加一些自定的区域(Regions),可以打开\themes\engines\phptemplate\phptemplate.engine

假设你的主题为:skin1

路径为:\sites\all\themes\skin1

复制下列代码到你的主题template.php,并修改

function phptemplate_regions() {
  return array(
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'content' => t('content'),
       'header' => t('header'),
       'footer' => t('footer')
  );
}

修改后为

function skin1_regions() {
  return array(
       'content_top' => t('content top'),
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'content' => t('content'),
       'header' => t('header'),
       'footer' => t('footer')
  );
}

function skin1_regions() {

skin1是主题的名字

       'content_top' => t('content top'),

left_top是我们增加的区域(Regions)

然后就可以把$left_top放在page.tpl.php的合适位置,使用:

<?php print $content_top ?>

接着到 “管理--站点创建--区块”,编辑和新增一个区块就能设置到该区域(Regions)

template.php的修改方法请参考附件:drupal5.x_template.php_.txt
page.tpl.php的修改方法请参考附件:drupal5.x_page.tpl_.php_.txt
如果浏览附件出现乱码,请将网页编码改成UTF-8

附件大小
drupal5.x_page.tpl_.php_.txt3.73 KB
drupal5.x_template.php_.txt2.72 KB