笔记: Drupal Theming

新的模版有一個比較特別的地方, 就是自定了三個位於頁尾的regions, 而沒有使用panels.

當然, 第一是效能的考慮, 二來, 因為每一頁都會有這三個頁尾區 製作眾多panels 只費時失事

增加regions是theme 的管轄範圍 初初我也感到意外, 但為了保持彈性和可定製性 留在theme 的層面也是相當的合理 定製也只需要初階的編程能力 一般的模版開發者是可以應付得來的

在template.php 之內, 定義一個函數:

<?php
function mytheme_regions(){
  return array(
    'right' => t('right sidebar'),
    'content' => t('content'),
    'header' => t('header'),
    'footer' => t('footer'),
    'bottom_left' => t('bottom left'),
    'bottom_center' => t('bottom center'),
    'bottom_right' => t('bottom right'),
  );
}
?>

mytheme 是這個theme的名字, 那樣, $bottomright, $bottomleft, $bottom_center 等的變數就會出現在page.tpl.php 之內 你可以將它們放到自定的位置, div 之內

//page.tpl.php
<?php if ( $bottom_left || $bottom_center || $bottom_right || $feed_icons ):?>
……

到 admin->site building->blocks 就會看到有’bottom left’ 等等的選項了

原文地址