Revision of 教學: 建立 Zen subtheme from Mon, 2011-12-19 17:47

Zen 稱它是 Drupal 內的最好的初始版型Drupal.
"如果你要建立一個符合規範的版型, 你會發覺, 使用 Zen 會比修改 Garland 或者 Bluemarine 容易得多"

它的 README 有一步一步的教學:
1. 將 Zen 內的 STARTERKIT folder 複製到 zen 之外, 並修改資料夾名稱為你的版型的名稱.
但留意, 版型的名稱一定使用小階的英文字母作開頭, 名稱只可以包含小階的英文字母, 數字和底線 (underscores)

例如, 複雜 sites/all/themes/zen/STARTERKIT 資料夾, 重新命名為 sites/all/themes/foo
這個步驟的目的是令你的客製版型 (sub-theme) 有一個自己的資料夾. 這會令 zen 版型的升級更容易.

2. 在你的新版型的資料夾, 將 STARTERKIT.info.txt 重新命名為你的版型的名稱, 然後移除 .txt 這個副檔名. 再修改 .info 檔案內的 "name" 和 "description" 欄位

例如, 重命名 foo/STARTERKIT.info.txt 為 foo/foo.info.
將 foo.info 內的 "name = Zen Sub-theme Starter Kit" 修改為 "name = Foo" and
"description = Read..." 修改為 "description = A Zen sub-theme"

.info 檔案是提供一些有關這個版型的基本資料給 Drupal: 名稱, 簡介, 功能, 區域, 包含的 CSS 檔和 JS 檔等. 詳情可以到 http://drupal.org/node/171205 了解更多

最後, 到 admin/build/themes 以更新 Drupal 6 的緩存

3.
3. By default your new sub-theme is using a fixed-width layout. If you want a
liquid layout for your theme, delete the unneeded layout-fixed.css and
layout-fixed-rtl.css files and edit your sub-theme's .info file and replace
the reference to layout-fixed.css with layout-liquid.css.

For example, edit foo/foo.info and change this line:
stylesheets[all][] = css/layout-fixed.css
to:
stylesheets[all][] = css/layout-liquid.css

Why? The "stylesheets" lines in your .info file describe the media type
and path to the CSS file you want to include. The format for these lines
is: stylesheets[MEDIA][] = path/to/file.css

Then, visit your site's admin/build/themes to refresh Drupal 6's cache of
.info file data.

Alternatively, if you are more familiar with a different CSS layout method,
such as Blueprint or 960.gs, you can replace the "css/layout-fixed.css" line
in your .info file with a line pointing at your choice of layout CSS file.

4. Edit the template.php and theme-settings.php files in your sub-theme's
folder; replace ALL occurrences of "STARTERKIT" with the name of your
sub-theme.

For example, edit foo/template.php and foo/theme-settings.php and replace
every occurrence of "STARTERKIT" with "foo".

It is recommended to use a text editing application with search and
"replace all" functionality.

5. Log in as an administrator on your Drupal site and go to Administer > Site
building > Themes (admin/build/themes) and enable your new sub-theme.

6. Internet explorer has a nasty bug that limits you to 31 stylsheets total. To
get around this limitation during theme development, download, install and
configure the "IE CSS Optimizer" module.

http://drupal.org/project/ie_css_optimizer

On a production server, you should enable full optimization of the "Optimize
CSS files" option on the Admin Performance page at
admin/settings/performance.

Optional:

7. MODIFYING ZEN CORE TEMPLATE FILES:
If you decide you want to modify any of the .tpl.php template files in the
zen folder, copy them to your sub-theme's folder before making any changes.
And then rebuild the theme registry.

For example, copy zen/templates/page.tpl.php to foo/templates/page.tpl.php.

8. THEMEING DRUPAL'S SEARCH FORM:
Copy the search-theme-form.tpl.php template file from the modules/search/
folder and place it in your sub-theme's folder. And then rebuild the theme
registry.

You can find a full list of Drupal templates that you can override in the
templates/README.txt file or http://drupal.org/node/190815

Why? In Drupal 6 theming, if you want to modify a template included by a
module, you should copy the template file from the module's directory to
your sub-theme's directory and then rebuild the theme registry. See the
Drupal 6 Theme Guide for more info: http://drupal.org/node/173880

Google