狠狠撸

狠狠撸Share a Scribd company logo
深入淺出 Drupal 版型設計
         Chris Wu / Fliegen Creative
Chris Wu

? aka. Amouro



? 賦格創意/ 集緻設計
  ? 網站設計
  ? 會議企劃



? Drupal 經驗 2.5 年
Theme

? 版型? 佈景主題,視覺介面,介面設計

   Drupal Core
        Module

             Interface

                         User
Skills

            工程師                             設計師
? 程式設計師,前端工程師                   ? UI 設計師,網頁設計師

? PHP? Of course!               ? HTML + CSS + DIV Layout

? Drupal Template/ API          ? Drupal Template
   ? .info / .tpl.php             ? .info
   ? Core API/ additional API     ? .tpl.php

? CSS + DIV Layout              ? PHP? Yes!
                                  ? Print
                                  ? Array
Find & Select a theme

? Easy
  ? 找個喜歡的漂亮版型
  ? 版面規劃符合需求

? Advance
  ? 設計!
  ? 尋找並安裝適合發展的基礎版型
  ? 切圖,改寫CSS

? Hardcore
  ? 親手從頭打造
EASY
EASY
SUPER EASY!
SUPER EASY!


              http://boldy.dev.garethalexander.co.uk/
HARDCORE!
ADVANCE

? Base Themes
   ? ZEN – John Albin
   ? Adaptive theme
   ? Fusion
   ? Blueprint
   ? Omega




? Documents of Contributed themes (http://drupal.org/node/196218)
Theme Guide
認識版型程式
Basic – 基本中的基本

? Drupal 6 - Garland

? Drupal 7 - Bartik

? 安裝版型
How the Theme system Works
.info (必備)
.info (必備)

? 編碼:UTF-8 檔首無BOM (Byte Order Mark)

? Keys
  ? screenshot = screenshot_theme.png
  ? regions[left] = Left Sidebar
    regions[right] = Right Sidebar
    regions[my_region] = Customized Region
  ? stylesheets[all][] = style.css //D6 default
    stylesheets[all][] = theStyle.css
    ;Add a style sheet with media query
    stylesheets[screen and (max-width: 600px)][] = theStyle600.css
  ? scripts[] = myscript.js
Region Variables

? regions[left] = Left Sidebar
   regions[right] = Right Sidebar
   regions[content] = Content
   regions[my_region] = Customized Region

? 輸出 Region 的內容
   ? <?php print $left; ?>
   ? <?php print $my_region;?>


   ? <?php print render($page[‘left’]); ?>
   ? <?php print render($page[‘my_region’]); ?>
區塊比較

  Drupal 6   Drupal 7
清除版型快取

? 修改過 .info 檔案後,務必清除 Cache 才能以新設定運作

? 清除方法
 ? Drupal 7: Administration > Configuration > Development > Performance
     (admin/config/development/performance)
 ? Drupal 6: Administer > Site configuration > Performance
     (admin/settings/performance)


 ? Admin menu, Drush, 版型設定(Zen, Fusion, AT)


 ? 小技巧:前往版型列表
    ?   D6: 網站建置 -> 版型 (Site building -> Themes)
    ?   D7: 外觀 ( Appearance)
樣板 .tpl.php
.tpl.php
用以輸出各階段的內容
?   Region 在 Page 呈現的版型配置
?   Block 在 Region 呈現的版型配置
page.tpl.php 產生主內容 (Drupal 7)
<div id="content">
  <?php print render($page['content']); ?>
</div>
page.tpl.php 產生主內容 (Drupal 6)
<div id="content">
  <?php print $content; ?>
</div>
regions[name] = Region Name

               D7 Regions                                   D6 Regions
? $page['content']: The main content of          ? $content
    the current page.
                                                 ? $sidebar_first
? $page['sidebar_first']: Items for the first
    sidebar.

? <?php if ($page[‘sidebar_first’]): ?>          ? <?php if($sidebar_first): ?>
      <?php print render($page[‘content’]); ?>         <div id=“sidebar-first”>
    <?php endif; ?>                                      <?php print $sidebar_first; ?>
                                                       </div>
                                                     <?php endif; ?>
Override 覆寫 .tpl.php
? 核心模組當中都有預設樣板                    ? Block
  (.tpl.php)                          “module/block/…”
                                      ? block.tpl.php**
? 以 D7 為例:
  ? System:                       ? Taxonomy
     “module/system/…”                “module/taxonomy/…”
     ? page.tpl.org                   ? taxonomy-term.tpl.php*
     ? maintenance-page.tpl.php
     ? region.tpl.php*
  ? User:
                                  *: new in D7
     “module/user/…”
     ? user-picture.tpl.php       **: was in “module/system/…”
     ? user-profile.tpl.php
Override 覆寫 .tpl.php
? block--[region|[module|--delta]].tpl.php   ? node--[type|nodeid].tpl.php
   1.   block--module--delta.tpl.php            1.   node--nodeid.tpl.php
   2.   block--module.tpl.php                   2.   node--type.tpl.php
   3.   block--region.tpl.php                   3.   node.tpl.php

? comment--[node-type].tpl.php               ? page--[front|internal/path].tpl.php
                                                1.   page--node--edit.tpl.php
                                                2.   page--node--1.tpl.php
                                                3.   page--node.tpl.php
                                                4.   page.tpl.php


? field--[type|name[--content-type]|content-type].tpl.php
以 Adaptive theme 為例
Take AT for instance.
.tpl.php 版本差異比較

         Drupal 6                     Drupal 7
? page-node-edit.tpl.php   ? page--node--edit.tpl.php

? node-mytype.tpl.php      ? node--mytype.tpl.php
                              ? node--long-content-type.tpl.php
撰寫 .tpl.php
整形前
整形後
node-product.tpl.php
找出要使用的資料
(value)
<pre>
 <?php print_r($node); ?>
</pre>


$node->nid
$node->status
找出要使用的資料
(value)

$node->field_fieldname[0][“view’]


$node->field_main_image[0][“filepath”]
Layout with DIV
<div id=“custom-id”>
  <h2> Title </h2>
  <p> Body </p>
  <div id=“sub-custom-id”>
    <div class=“first”> <?php ?> </div>
    <div class=“second”></div>
    <div class=“third”></div>
  </div> <!-- end of #sub-custom-id -->
</div> <!-- end of #custom-id -->
After edit
*再次清除版型快取(cache)
Feature Blocks
設計漂亮的區塊標題
DIV + CSS
配合 Firebug 或是 Chrome 的開發人員工具
小技巧: F12
Time for Q&A
amouro@laconique.com.tw
Ad

Recommended

[DCTPE2010] Drupal 模組開發入門
[DCTPE2010] Drupal 模組開發入門
Drupal Taiwan
?
使用 Eloquent ORM
使用 Eloquent ORM
Shengyou Fan
?
Sina App Quick Guide 1
Sina App Quick Guide 1
guestf4aed35
?
开发流程与工具介绍
开发流程与工具介绍
Shengyou Fan
?
HTML 語法教學
HTML 語法教學
Shengyou Fan
?
Migrations 與 Schema操作
Migrations 與 Schema操作
Shengyou Fan
?
I Love Joomla! 佈景製作教學 0212
I Love Joomla! 佈景製作教學 0212
Asika Simon
?
【 I Love Joomla 】- Joomla!佈景製作教學
【 I Love Joomla 】- Joomla!佈景製作教學
ilovejoomla
?
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
Schema & Migration操作
Schema & Migration操作
Shengyou Fan
?
CSS 語法教學
CSS 語法教學
Shengyou Fan
?
Patterns in Zend Framework
Patterns in Zend Framework
Jace Ju
?
5.网站设计与前端框架
5.网站设计与前端框架
Nelson Chen
?
Model & Seeding整合
Model & Seeding整合
Shengyou Fan
?
advanced introduction to codeigniter
advanced introduction to codeigniter
Bo-Yi Wu
?
开发环境建置
开发环境建置
Shengyou Fan
?
编辑器设计2
编辑器设计2
yiming he
?
Eloquent ORM
Eloquent ORM
Shengyou Fan
?
CRUD 綜合運用
CRUD 綜合運用
Shengyou Fan
?
Eloquent ORM
Eloquent ORM
Shengyou Fan
?
工作坊总结
工作坊总结
Shengyou Fan
?
[译]Efficient, maintainable CSS
[译]Efficient, maintainable CSS
jeannewoo
?
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
Migrations 與 Schema 操作
Migrations 與 Schema 操作
Shengyou Fan
?
CRUD 綜合運用
CRUD 綜合運用
Shengyou Fan
?
常见设计模式介绍
常见设计模式介绍
Jace Ju
?
CRUD 綜合應用
CRUD 綜合應用
Shengyou Fan
?
Mongodb
Mongodb
bj
?
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
DrupalCamp Taipei 2012 迷人的有「型」網站
DrupalCamp Taipei 2012 迷人的有「型」網站
Hipfox
?

More Related Content

What's hot (20)

View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
Schema & Migration操作
Schema & Migration操作
Shengyou Fan
?
CSS 語法教學
CSS 語法教學
Shengyou Fan
?
Patterns in Zend Framework
Patterns in Zend Framework
Jace Ju
?
5.网站设计与前端框架
5.网站设计与前端框架
Nelson Chen
?
Model & Seeding整合
Model & Seeding整合
Shengyou Fan
?
advanced introduction to codeigniter
advanced introduction to codeigniter
Bo-Yi Wu
?
开发环境建置
开发环境建置
Shengyou Fan
?
编辑器设计2
编辑器设计2
yiming he
?
Eloquent ORM
Eloquent ORM
Shengyou Fan
?
CRUD 綜合運用
CRUD 綜合運用
Shengyou Fan
?
Eloquent ORM
Eloquent ORM
Shengyou Fan
?
工作坊总结
工作坊总结
Shengyou Fan
?
[译]Efficient, maintainable CSS
[译]Efficient, maintainable CSS
jeannewoo
?
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
Migrations 與 Schema 操作
Migrations 與 Schema 操作
Shengyou Fan
?
CRUD 綜合運用
CRUD 綜合運用
Shengyou Fan
?
常见设计模式介绍
常见设计模式介绍
Jace Ju
?
CRUD 綜合應用
CRUD 綜合應用
Shengyou Fan
?
Mongodb
Mongodb
bj
?
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
Schema & Migration操作
Schema & Migration操作
Shengyou Fan
?
Patterns in Zend Framework
Patterns in Zend Framework
Jace Ju
?
5.网站设计与前端框架
5.网站设计与前端框架
Nelson Chen
?
Model & Seeding整合
Model & Seeding整合
Shengyou Fan
?
advanced introduction to codeigniter
advanced introduction to codeigniter
Bo-Yi Wu
?
编辑器设计2
编辑器设计2
yiming he
?
[译]Efficient, maintainable CSS
[译]Efficient, maintainable CSS
jeannewoo
?
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
Migrations 與 Schema 操作
Migrations 與 Schema 操作
Shengyou Fan
?
常见设计模式介绍
常见设计模式介绍
Jace Ju
?
Mongodb
Mongodb
bj
?

Similar to Drupal 版型設計 - 瞭解版型程式 (20)

View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
DrupalCamp Taipei 2012 迷人的有「型」網站
DrupalCamp Taipei 2012 迷人的有「型」網站
Hipfox
?
Introduction to MVC of CodeIgniter 2.1.x
Introduction to MVC of CodeIgniter 2.1.x
Bo-Yi Wu
?
Django step0
Django step0
永昇 陳
?
Django development
Django development
loveyudu
?
旺铺前端设计和实现
旺铺前端设计和实现
hua qiu
?
模块加载策略 - 2012 SDCC, 北京
模块加载策略 - 2012 SDCC, 北京
Joseph Chiang
?
笔贬笔通用程序的模板运行机制
笔贬笔通用程序的模板运行机制
horseluke
?
NextGen
NextGen
potatongy
?
CSS 培训
CSS 培训
S S
?
贬迟尘濒5和肠蝉蝉3入门
贬迟尘濒5和肠蝉蝉3入门
Xiujun Ma
?
Free Marker中文文档
Free Marker中文文档
yiditushe
?
Introduction to CodeIgniter
Introduction to CodeIgniter
Chun-Kai Wang
?
Web development with zend framework
Web development with zend framework
thinkinlamp
?
Spring 2.x 中文
Spring 2.x 中文
Guo Albert
?
顿颈蝉肠耻锄技术交流
顿颈蝉肠耻锄技术交流
pigso
?
编辑器设计Kissy editor
编辑器设计Kissy editor
taobao.com
?
Inside the browser
Inside the browser
otakustay
?
窜别苍肠补谤迟网站模板复制过程
窜别苍肠补谤迟网站模板复制过程
xiaochenlbm
?
Php
Php
paitoubing
?
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
Shengyou Fan
?
DrupalCamp Taipei 2012 迷人的有「型」網站
DrupalCamp Taipei 2012 迷人的有「型」網站
Hipfox
?
Introduction to MVC of CodeIgniter 2.1.x
Introduction to MVC of CodeIgniter 2.1.x
Bo-Yi Wu
?
Django development
Django development
loveyudu
?
旺铺前端设计和实现
旺铺前端设计和实现
hua qiu
?
模块加载策略 - 2012 SDCC, 北京
模块加载策略 - 2012 SDCC, 北京
Joseph Chiang
?
笔贬笔通用程序的模板运行机制
笔贬笔通用程序的模板运行机制
horseluke
?
CSS 培训
CSS 培训
S S
?
贬迟尘濒5和肠蝉蝉3入门
贬迟尘濒5和肠蝉蝉3入门
Xiujun Ma
?
Free Marker中文文档
Free Marker中文文档
yiditushe
?
Introduction to CodeIgniter
Introduction to CodeIgniter
Chun-Kai Wang
?
Web development with zend framework
Web development with zend framework
thinkinlamp
?
Spring 2.x 中文
Spring 2.x 中文
Guo Albert
?
顿颈蝉肠耻锄技术交流
顿颈蝉肠耻锄技术交流
pigso
?
编辑器设计Kissy editor
编辑器设计Kissy editor
taobao.com
?
Inside the browser
Inside the browser
otakustay
?
窜别苍肠补谤迟网站模板复制过程
窜别苍肠补谤迟网站模板复制过程
xiaochenlbm
?
Ad

More from Chris Wu (10)

Effective Designer - 有效率的設計師
Effective Designer - 有效率的設計師
Chris Wu
?
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Chris Wu
?
MRT Express 極速北捷(UI/UX Designers' Night)
MRT Express 極速北捷(UI/UX Designers' Night)
Chris Wu
?
Drupal 8 版型開發變革
Drupal 8 版型開發變革
Chris Wu
?
從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWD
Chris Wu
?
Responsive design on drupal
Responsive design on drupal
Chris Wu
?
I use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 Drupal
Chris Wu
?
那些年,我们一起搞的金流
那些年,我们一起搞的金流
Chris Wu
?
DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介
Chris Wu
?
Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會
Chris Wu
?
Effective Designer - 有效率的設計師
Effective Designer - 有效率的設計師
Chris Wu
?
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Chris Wu
?
MRT Express 極速北捷(UI/UX Designers' Night)
MRT Express 極速北捷(UI/UX Designers' Night)
Chris Wu
?
Drupal 8 版型開發變革
Drupal 8 版型開發變革
Chris Wu
?
從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWD
Chris Wu
?
Responsive design on drupal
Responsive design on drupal
Chris Wu
?
I use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 Drupal
Chris Wu
?
那些年,我们一起搞的金流
那些年,我们一起搞的金流
Chris Wu
?
DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介
Chris Wu
?
Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會
Chris Wu
?
Ad

Drupal 版型設計 - 瞭解版型程式