SlideShare une entreprise Scribd logo
1  sur  38
深入淺出 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

Contenu connexe

Tendances

View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎Shengyou Fan
 
Schema & Migration操作
Schema & Migration操作Schema & Migration操作
Schema & Migration操作Shengyou Fan
 
Patterns in Zend Framework
Patterns in Zend FrameworkPatterns in Zend Framework
Patterns in Zend FrameworkJace Ju
 
5.網站設計與前端框架
5.網站設計與前端框架5.網站設計與前端框架
5.網站設計與前端框架Nelson Chen
 
Model & Seeding整合
Model & Seeding整合Model & Seeding整合
Model & Seeding整合Shengyou Fan
 
advanced introduction to codeigniter
advanced introduction to codeigniteradvanced introduction to codeigniter
advanced introduction to codeigniterBo-Yi Wu
 
開發環境建置
開發環境建置開發環境建置
開發環境建置Shengyou Fan
 
编辑器设计2
编辑器设计2编辑器设计2
编辑器设计2yiming he
 
[译]Efficient, maintainable CSS
[译]Efficient, maintainable CSS[译]Efficient, maintainable CSS
[译]Efficient, maintainable CSSjeannewoo
 
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎Shengyou Fan
 
Migrations 與 Schema 操作
Migrations 與 Schema 操作Migrations 與 Schema 操作
Migrations 與 Schema 操作Shengyou Fan
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹Jace Ju
 
Mongodb
MongodbMongodb
Mongodbbj
 

Tendances (20)

View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
 
Schema & Migration操作
Schema & Migration操作Schema & Migration操作
Schema & Migration操作
 
CSS 語法教學
CSS 語法教學CSS 語法教學
CSS 語法教學
 
Patterns in Zend Framework
Patterns in Zend FrameworkPatterns in Zend Framework
Patterns in Zend Framework
 
5.網站設計與前端框架
5.網站設計與前端框架5.網站設計與前端框架
5.網站設計與前端框架
 
Model & Seeding整合
Model & Seeding整合Model & Seeding整合
Model & Seeding整合
 
advanced introduction to codeigniter
advanced introduction to codeigniteradvanced introduction to codeigniter
advanced introduction to codeigniter
 
開發環境建置
開發環境建置開發環境建置
開發環境建置
 
编辑器设计2
编辑器设计2编辑器设计2
编辑器设计2
 
Eloquent ORM
Eloquent ORMEloquent ORM
Eloquent ORM
 
CRUD 綜合運用
CRUD 綜合運用CRUD 綜合運用
CRUD 綜合運用
 
Eloquent ORM
Eloquent ORMEloquent ORM
Eloquent ORM
 
工作坊總結
工作坊總結工作坊總結
工作坊總結
 
[译]Efficient, maintainable CSS
[译]Efficient, maintainable CSS[译]Efficient, maintainable CSS
[译]Efficient, maintainable CSS
 
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
 
Migrations 與 Schema 操作
Migrations 與 Schema 操作Migrations 與 Schema 操作
Migrations 與 Schema 操作
 
CRUD 綜合運用
CRUD 綜合運用CRUD 綜合運用
CRUD 綜合運用
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹
 
CRUD 綜合應用
CRUD 綜合應用CRUD 綜合應用
CRUD 綜合應用
 
Mongodb
MongodbMongodb
Mongodb
 

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

View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎Shengyou Fan
 
DrupalCamp Taipei 2012 迷人的有「型」網站
DrupalCamp Taipei 2012 迷人的有「型」網站DrupalCamp Taipei 2012 迷人的有「型」網站
DrupalCamp Taipei 2012 迷人的有「型」網站Hipfox
 
Introduction to MVC of CodeIgniter 2.1.x
Introduction to MVC of CodeIgniter 2.1.xIntroduction to MVC of CodeIgniter 2.1.x
Introduction to MVC of CodeIgniter 2.1.xBo-Yi Wu
 
Django development
Django developmentDjango development
Django developmentloveyudu
 
旺铺前端设计和实现
旺铺前端设计和实现旺铺前端设计和实现
旺铺前端设计和实现hua qiu
 
模块加载策略 - 2012 SDCC, 北京
模块加载策略 - 2012 SDCC, 北京模块加载策略 - 2012 SDCC, 北京
模块加载策略 - 2012 SDCC, 北京Joseph Chiang
 
PHP通用程序的模板运行机制
PHP通用程序的模板运行机制PHP通用程序的模板运行机制
PHP通用程序的模板运行机制horseluke
 
CSS 培训
CSS 培训CSS 培训
CSS 培训S S
 
Html5和css3入门
Html5和css3入门Html5和css3入门
Html5和css3入门Xiujun Ma
 
Free Marker中文文档
Free Marker中文文档Free Marker中文文档
Free Marker中文文档yiditushe
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniterChun-Kai Wang
 
Web development with zend framework
Web development with zend frameworkWeb development with zend framework
Web development with zend frameworkthinkinlamp
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文Guo Albert
 
Discuz技术交流
Discuz技术交流Discuz技术交流
Discuz技术交流pigso
 
编辑器设计Kissy editor
编辑器设计Kissy editor编辑器设计Kissy editor
编辑器设计Kissy editortaobao.com
 
Inside the browser
Inside the browserInside the browser
Inside the browserotakustay
 
Zencart网站模板复制过程
Zencart网站模板复制过程Zencart网站模板复制过程
Zencart网站模板复制过程xiaochenlbm
 

Similaire à Drupal 版型設計 - 瞭解版型程式 (20)

View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
 
DrupalCamp Taipei 2012 迷人的有「型」網站
DrupalCamp Taipei 2012 迷人的有「型」網站DrupalCamp Taipei 2012 迷人的有「型」網站
DrupalCamp Taipei 2012 迷人的有「型」網站
 
Introduction to MVC of CodeIgniter 2.1.x
Introduction to MVC of CodeIgniter 2.1.xIntroduction to MVC of CodeIgniter 2.1.x
Introduction to MVC of CodeIgniter 2.1.x
 
Django step0
Django step0Django step0
Django step0
 
Django development
Django developmentDjango development
Django development
 
旺铺前端设计和实现
旺铺前端设计和实现旺铺前端设计和实现
旺铺前端设计和实现
 
模块加载策略 - 2012 SDCC, 北京
模块加载策略 - 2012 SDCC, 北京模块加载策略 - 2012 SDCC, 北京
模块加载策略 - 2012 SDCC, 北京
 
PHP通用程序的模板运行机制
PHP通用程序的模板运行机制PHP通用程序的模板运行机制
PHP通用程序的模板运行机制
 
NextGen
NextGenNextGen
NextGen
 
CSS 培训
CSS 培训CSS 培训
CSS 培训
 
Html5和css3入门
Html5和css3入门Html5和css3入门
Html5和css3入门
 
Free Marker中文文档
Free Marker中文文档Free Marker中文文档
Free Marker中文文档
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniter
 
Web development with zend framework
Web development with zend frameworkWeb development with zend framework
Web development with zend framework
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文
 
Discuz技术交流
Discuz技术交流Discuz技术交流
Discuz技术交流
 
编辑器设计Kissy editor
编辑器设计Kissy editor编辑器设计Kissy editor
编辑器设计Kissy editor
 
Inside the browser
Inside the browserInside the browser
Inside the browser
 
Zencart网站模板复制过程
Zencart网站模板复制过程Zencart网站模板复制过程
Zencart网站模板复制过程
 
Php
Php Php
Php
 

Plus de Chris Wu

Effective Designer - 有效率的設計師
Effective Designer - 有效率的設計師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...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)MRT Express 極速北捷(UI/UX Designers' Night)
MRT Express 極速北捷(UI/UX Designers' Night)Chris Wu
 
Drupal 8 版型開發變革
Drupal 8 版型開發變革Drupal 8 版型開發變革
Drupal 8 版型開發變革Chris Wu
 
從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWD從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWDChris Wu
 
Responsive design on drupal
Responsive design on drupalResponsive design on drupal
Responsive design on drupalChris Wu
 
I use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 DrupalI use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 DrupalChris Wu
 
那些年,我們一起搞的金流
那些年,我們一起搞的金流那些年,我們一起搞的金流
那些年,我們一起搞的金流Chris Wu
 
DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介Chris Wu
 
Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會Chris Wu
 

Plus de Chris Wu (10)

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

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