SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Drupal 6 的 CCK / Views運用
      獨立工作者 黎韋志
大綱 - CCK

● CCK 的實務應用 - 從檔案管理說起
● 跟檔案有關的模組
● 檔案上傳
● 影音檔案播放
● 整合應用
大綱 -Views

● Views 樣板中的樣板
● Views 裏面你該知道的三個函數
● 取得某個 Views 執行結果的(總)列數
● 兩個常用的 Views 模組
● Attachment Display 的限制
● 複雜的 Views 欄位排版技巧
CCK 的實務應用 - 從檔案管理說起

● 一個節點 (Node) 就是一個原子 (Atom)
● 禁用 Upload,只用 FileField
● 硬碟很便宜,檔案重複上傳沒關係
● 資訊只要最新的是對的就行了
● 發現舊的資訊有錯再改就好,不需要求完美
● 人會來來去去,可以維護的系統才是好系統
跟檔案有關的模組

    ● FileField
    ● Embedded Media Field 
 
    ● Transliteration
    ● FileField Paths
 
    ● FileField Sources
    ● SWF Tools
 
    ● Insert
    ● Pathologic
檔案上傳

    ● Transliteration
       ○ 將上傳(中文)檔案的檔名依照音譯來更名
       ○ Windows 執行 Drupal 配合 FileField 時必裝
 
    ● FileField Paths
       ○ 配合 Token 將上傳的檔案放到不同的目錄下
           ■ 例如:node/[type]
       ○ 配合 Token 將上傳的檔案更名
           ■ 例如:[filefield-fid].[filefield-extension] 
 
影音檔案播放

    ● FileField Sources
       ○ 若檔案太大,可利用 FTP 上傳檔案到某個目錄下,再利用
          FileField Sources 模組將檔案移動到指定的目錄中
 
    ●  影音檔案播放:SWF Tools + JW Player
       ○ 可以同時支援 FileField 與 Embedded Media Field
       ○ 在內容類型裡面的顯示設定指定 FileField 與 Embedded
         Media Field 欄位的顯示方式
整合應用

    ● 在內文中插入檔案:Insert
       ○ 將 FileFiled 欄位的檔案插入 Body 裡面
       ○ 可配合 ImageCache 插入不同形式的圖片
 
    ● 路徑修正:Pathologic
       ○ Insert 產生的路徑是絕對路徑
       ○ 搬移網站時可利用 Pathologic 調整路徑
       ○ 要打開 Clean URL
Views 樣板中的樣板

    ● 每個 Views 中的 Default Display 可說是該 Views 的樣板
       ○ 簡單的繼承觀念
 
    ● 不過每次新建一個 Views 都要設定類似的 Default Display 實
      在是太麻煩了
       ○ 懶人的想法
 
    ● 借用 Drupal 7 的 Entity 的觀念,可以建立 Node、User、Term
      的樣板 Views
       ○ 用 Clone 代替 Add
各種不同的樣板簡介

     ● 常用的大致分成兩類:
        ○ list 型:撈出一群 Entity
        ○ id 型:撈出特定 id / name 的 Entity(常配合 Panels 做該
          Entity View 的預設顯示方式的改寫)
 
     ● 命名方式:_Entity Type(_list)
        ○ 以 Node 來說,就有 _node_list 跟 _node 兩種
 
     ● 在管理上,若需要的 Views 不多,也可以只做 list 型的樣板
  
Node List 樣板(_node_list)

    ● Filters
       ○ Node: Published = Yes
       ○ Node: Type = Unknown
       ○ Node transaltion: Content negotiation(多語系專用)
 
    ● Sort criteria
       ○ Node: post date = desc
 
    ● Fields
       ○ Node: nid(隱藏、非連結、不要有千分位的逗號)
       ○ Node: Title(做成連結)
Node 樣板(_node)

    ● 除了跟 Node List 樣板一樣的設定外,再加上底下的設定
 
    ●  Argument
        ○ Node: Nid 
 
    ● Use Pager: 1 item
Term List 樣板(_term_list)

    ● Filters
       ○ Taxonomy: Vocabulary = Unknown
 
    ● Sort criteria
       ○ Taxonomy: Weight = asc
 
    ● Fields
       ○ Taxonomy: Term ID(隱藏、非連結、不要有千分位的逗
         號)
       ○ Taxonomy: Term(做成連結)
Term 樣板(_term)

    ● 除了跟 Term List 樣板一樣的設定外,再加上底下的設定
 
    ●  Argument
        ○ Taxonomy: Term ID
 
    ● Use Pager: 1 item
User List 樣板(_user_list)

    ● Filters
       ○ User: Active = Yes
       ○ User: Roles = Unknown
 
    ● Sort criteria
       ○ User: Created date = desc
 
    ● Fields
       ○ User: Uid(隱藏、非連結、不要有千分位的逗號)
       ○ User: Name(做成連結)
User 樣板(_user)

    ● 除了跟 User List 樣板一樣的設定外,再加上底下的設定
 
    ●  Argument
        ○ User: Uid
 
    ● Use Pager: 1 item
Views 裏面你該知道的三個函數

    ● views_embed_view($name, $display_id = 'default')
        ○ 取得某個 Views 的執行結果(輸出)
 
    ● views_get_view_result($name, $display_id = NULL)
        ○ 取得某個 Views 的執行結果(陣列) 
 
    ● 參數說明
       ○ $name: Views 的名稱
       ○ $display_id: Display 的名稱
       ○ 第三個參數以後是要傳進該 Views 的參數
Views 裏面你該知道的三個函數

● views_get_view($name, $reset = FALSE)
    ○ $name: Views 的名稱
    ○ $reset: 重新從資料庫中載入 Views 的設定
取得某個 Views 執行結果的(總)列數

  ● 取得執行結果的列數
Count(views_get_view_result($name, $display_id));
 
  ● 取得執行結果的總列數
    $view = views_get_view($name);
    $view->get_total_rows = true;
    $view->execute($display_id);
    $count = $view->total_rows;
兩個常用的 Views 模組

    ● Embed Views Display
       ○ 非特定用途的 Views Display
       ○ 常配合 Panels 和 Customfield: PHP code 來組合資訊
 
    ●  Views Custom Field
        ○ Customfield: Markup 類似 Global: Custom text
        ○ Customfield: PHP code 可在欄位中插入 PHP 程式碼
        ○ Customfield: Rownumber 提供欄位項次資訊
Attachment Display v.s. Customfield:
PHP code
    ● Attachment Display 的限制
       ○ 需在同一個 Views 裡面
       ○ 傳入的參數要一致
       ○ 無法在欄位層次混排資訊
 
    ● 替代方案:Customfield: PHP code + views_embed_view
       ○ 可以取用不同 Views 的 Display
       ○ 傳入的參數可以不同(只要傳的是正確的就行)
       ○ 可配合 Global: Custom text 達成欄位層次的混排
       ○ 可以有複雜的顯示條件
複雜的 Views 欄位排版技巧

1. 把需要的欄位加入欄位設定中
2. 設定好這些欄位的顯示樣式
3. 將這些欄位排除在顯示之外
4. 最後加入 Global: Custom text ,寫出合適的 HTML 結構
5. 配合 CCS 把版面做出來

Mais conteúdo relacionado

Destaque

[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋Drupal Taiwan
 
[DCTPE2010] 開場:Drupal與Drupal台灣
[DCTPE2010] 開場:Drupal與Drupal台灣[DCTPE2010] 開場:Drupal與Drupal台灣
[DCTPE2010] 開場:Drupal與Drupal台灣Drupal Taiwan
 
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 1. 網站標案經驗分享 x 2
[DCTPE2011] 11) Drupal 是好的生財工具嗎?  1. 網站標案經驗分享 x 2[DCTPE2011] 11) Drupal 是好的生財工具嗎?  1. 網站標案經驗分享 x 2
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 1. 網站標案經驗分享 x 2Drupal Taiwan
 
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗Drupal Taiwan
 
[DCTPE2011] Drupal 7 的Fields/Views 運用
[DCTPE2011] Drupal 7 的Fields/Views 運用[DCTPE2011] Drupal 7 的Fields/Views 運用
[DCTPE2011] Drupal 7 的Fields/Views 運用Drupal Taiwan
 
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇Drupal Taiwan
 
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口Drupal Taiwan
 
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 shareDrupal Taiwan
 
[DCTPE2010] Open Hopen 政府網站的理想與現實
[DCTPE2010] Open Hopen 政府網站的理想與現實[DCTPE2010] Open Hopen 政府網站的理想與現實
[DCTPE2010] Open Hopen 政府網站的理想與現實Drupal Taiwan
 
[DCTPE2010] Biodiversity & Drupal
[DCTPE2010] Biodiversity & Drupal[DCTPE2010] Biodiversity & Drupal
[DCTPE2010] Biodiversity & DrupalDrupal Taiwan
 
[DCTPE2011] 7) Mobile Drupal(英/中雙語)
[DCTPE2011] 7) Mobile Drupal(英/中雙語)[DCTPE2011] 7) Mobile Drupal(英/中雙語)
[DCTPE2011] 7) Mobile Drupal(英/中雙語)Drupal Taiwan
 
[DCTPE2011] 10) Drupal與Facebook交朋友
[DCTPE2011] 10) Drupal與Facebook交朋友[DCTPE2011] 10) Drupal與Facebook交朋友
[DCTPE2011] 10) Drupal與Facebook交朋友Drupal Taiwan
 
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James LiuDrupal Taiwan
 
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)Drupal Taiwan
 
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例Drupal Taiwan
 
[DCTPE2010] Microsoft
[DCTPE2010] Microsoft[DCTPE2010] Microsoft
[DCTPE2010] MicrosoftDrupal Taiwan
 
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRMDrupal Taiwan
 
[DCTPE2010] Drupal 模組開發入門
[DCTPE2010] Drupal 模組開發入門[DCTPE2010] Drupal 模組開發入門
[DCTPE2010] Drupal 模組開發入門Drupal Taiwan
 
[DCTPE2011]Drupalthon intro
[DCTPE2011]Drupalthon intro[DCTPE2011]Drupalthon intro
[DCTPE2011]Drupalthon introDrupal Taiwan
 

Destaque (19)

[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋
 
[DCTPE2010] 開場:Drupal與Drupal台灣
[DCTPE2010] 開場:Drupal與Drupal台灣[DCTPE2010] 開場:Drupal與Drupal台灣
[DCTPE2010] 開場:Drupal與Drupal台灣
 
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 1. 網站標案經驗分享 x 2
[DCTPE2011] 11) Drupal 是好的生財工具嗎?  1. 網站標案經驗分享 x 2[DCTPE2011] 11) Drupal 是好的生財工具嗎?  1. 網站標案經驗分享 x 2
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 1. 網站標案經驗分享 x 2
 
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗
 
[DCTPE2011] Drupal 7 的Fields/Views 運用
[DCTPE2011] Drupal 7 的Fields/Views 運用[DCTPE2011] Drupal 7 的Fields/Views 運用
[DCTPE2011] Drupal 7 的Fields/Views 運用
 
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇
 
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口
 
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share
 
[DCTPE2010] Open Hopen 政府網站的理想與現實
[DCTPE2010] Open Hopen 政府網站的理想與現實[DCTPE2010] Open Hopen 政府網站的理想與現實
[DCTPE2010] Open Hopen 政府網站的理想與現實
 
[DCTPE2010] Biodiversity & Drupal
[DCTPE2010] Biodiversity & Drupal[DCTPE2010] Biodiversity & Drupal
[DCTPE2010] Biodiversity & Drupal
 
[DCTPE2011] 7) Mobile Drupal(英/中雙語)
[DCTPE2011] 7) Mobile Drupal(英/中雙語)[DCTPE2011] 7) Mobile Drupal(英/中雙語)
[DCTPE2011] 7) Mobile Drupal(英/中雙語)
 
[DCTPE2011] 10) Drupal與Facebook交朋友
[DCTPE2011] 10) Drupal與Facebook交朋友[DCTPE2011] 10) Drupal與Facebook交朋友
[DCTPE2011] 10) Drupal與Facebook交朋友
 
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
 
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)
 
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例
 
[DCTPE2010] Microsoft
[DCTPE2010] Microsoft[DCTPE2010] Microsoft
[DCTPE2010] Microsoft
 
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM
 
[DCTPE2010] Drupal 模組開發入門
[DCTPE2010] Drupal 模組開發入門[DCTPE2010] Drupal 模組開發入門
[DCTPE2010] Drupal 模組開發入門
 
[DCTPE2011]Drupalthon intro
[DCTPE2011]Drupalthon intro[DCTPE2011]Drupalthon intro
[DCTPE2011]Drupalthon intro
 

Semelhante a [DCTPE2011] Drupal 6 的 CCK/Views運用--黎偉志

20130325 mldm monday spide r
20130325 mldm monday spide r20130325 mldm monday spide r
20130325 mldm monday spide rChia-Chi Chang
 
Backbone js and requirejs
Backbone js and requirejsBackbone js and requirejs
Backbone js and requirejsChi-wen Sun
 
Django development
Django developmentDjango development
Django developmentloveyudu
 
認試軟體測試的世界 & TDD/BDD 入門
認試軟體測試的世界 & TDD/BDD 入門認試軟體測試的世界 & TDD/BDD 入門
認試軟體測試的世界 & TDD/BDD 入門wantingj
 
Drupalthon team report for Ubuntu TW
Drupalthon team report for Ubuntu TWDrupalthon team report for Ubuntu TW
Drupalthon team report for Ubuntu TWt ky
 
Drupal7第三堂
Drupal7第三堂Drupal7第三堂
Drupal7第三堂Hen Chen
 
SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4Rick Hwang
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniterChun-Kai Wang
 
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
 
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2Yang FaFa
 
SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4Rick Hwang
 
Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式Chris Wu
 
Chapter 4 models
Chapter 4 modelsChapter 4 models
Chapter 4 modelsEkman Hsieh
 
Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸Will Huang
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例Will Huang
 
Noder eyes for frontend guys
Noder eyes for frontend guysNoder eyes for frontend guys
Noder eyes for frontend guysHsu Ping Feng
 
團隊協作實戰DDD
團隊協作實戰DDD團隊協作實戰DDD
團隊協作實戰DDDJed Lin
 
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端 用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端 升煌 黃
 
Kindeditor 设计思路
Kindeditor 设计思路Kindeditor 设计思路
Kindeditor 设计思路luolonghao
 

Semelhante a [DCTPE2011] Drupal 6 的 CCK/Views運用--黎偉志 (20)

20130325 mldm monday spide r
20130325 mldm monday spide r20130325 mldm monday spide r
20130325 mldm monday spide r
 
Backbone js and requirejs
Backbone js and requirejsBackbone js and requirejs
Backbone js and requirejs
 
Django development
Django developmentDjango development
Django development
 
認試軟體測試的世界 & TDD/BDD 入門
認試軟體測試的世界 & TDD/BDD 入門認試軟體測試的世界 & TDD/BDD 入門
認試軟體測試的世界 & TDD/BDD 入門
 
Drupalthon team report for Ubuntu TW
Drupalthon team report for Ubuntu TWDrupalthon team report for Ubuntu TW
Drupalthon team report for Ubuntu TW
 
Drupal7第三堂
Drupal7第三堂Drupal7第三堂
Drupal7第三堂
 
SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniter
 
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
 
Using vim
Using vimUsing vim
Using vim
 
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
[Talk] 2013 06-02-hadoop整合應用-crawlzilla@hadoop q2
 
SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4SRE Study Notes - CH2,3,4
SRE Study Notes - CH2,3,4
 
Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式
 
Chapter 4 models
Chapter 4 modelsChapter 4 models
Chapter 4 models
 
Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸Angular 4 新手入門攻略完全制霸
Angular 4 新手入門攻略完全制霸
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
 
Noder eyes for frontend guys
Noder eyes for frontend guysNoder eyes for frontend guys
Noder eyes for frontend guys
 
團隊協作實戰DDD
團隊協作實戰DDD團隊協作實戰DDD
團隊協作實戰DDD
 
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端 用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
用 Standalone Component 來寫 Angular 吧! - STUDY4.TW 2023 小聚 - 聊前端
 
Kindeditor 设计思路
Kindeditor 设计思路Kindeditor 设计思路
Kindeditor 设计思路
 

[DCTPE2011] Drupal 6 的 CCK/Views運用--黎偉志

  • 1. Drupal 6 的 CCK / Views運用 獨立工作者 黎韋志
  • 2. 大綱 - CCK ● CCK 的實務應用 - 從檔案管理說起 ● 跟檔案有關的模組 ● 檔案上傳 ● 影音檔案播放 ● 整合應用
  • 3. 大綱 -Views ● Views 樣板中的樣板 ● Views 裏面你該知道的三個函數 ● 取得某個 Views 執行結果的(總)列數 ● 兩個常用的 Views 模組 ● Attachment Display 的限制 ● 複雜的 Views 欄位排版技巧
  • 4. CCK 的實務應用 - 從檔案管理說起 ● 一個節點 (Node) 就是一個原子 (Atom) ● 禁用 Upload,只用 FileField ● 硬碟很便宜,檔案重複上傳沒關係 ● 資訊只要最新的是對的就行了 ● 發現舊的資訊有錯再改就好,不需要求完美 ● 人會來來去去,可以維護的系統才是好系統
  • 5. 跟檔案有關的模組 ● FileField ● Embedded Media Field    ● Transliteration ● FileField Paths   ● FileField Sources ● SWF Tools   ● Insert ● Pathologic
  • 6. 檔案上傳 ● Transliteration ○ 將上傳(中文)檔案的檔名依照音譯來更名 ○ Windows 執行 Drupal 配合 FileField 時必裝   ● FileField Paths ○ 配合 Token 將上傳的檔案放到不同的目錄下 ■ 例如:node/[type] ○ 配合 Token 將上傳的檔案更名 ■ 例如:[filefield-fid].[filefield-extension]   
  • 7. 影音檔案播放 ● FileField Sources ○ 若檔案太大,可利用 FTP 上傳檔案到某個目錄下,再利用 FileField Sources 模組將檔案移動到指定的目錄中   ●  影音檔案播放:SWF Tools + JW Player ○ 可以同時支援 FileField 與 Embedded Media Field ○ 在內容類型裡面的顯示設定指定 FileField 與 Embedded Media Field 欄位的顯示方式
  • 8. 整合應用 ● 在內文中插入檔案:Insert ○ 將 FileFiled 欄位的檔案插入 Body 裡面 ○ 可配合 ImageCache 插入不同形式的圖片   ● 路徑修正:Pathologic ○ Insert 產生的路徑是絕對路徑 ○ 搬移網站時可利用 Pathologic 調整路徑 ○ 要打開 Clean URL
  • 9. Views 樣板中的樣板 ● 每個 Views 中的 Default Display 可說是該 Views 的樣板 ○ 簡單的繼承觀念   ● 不過每次新建一個 Views 都要設定類似的 Default Display 實 在是太麻煩了 ○ 懶人的想法   ● 借用 Drupal 7 的 Entity 的觀念,可以建立 Node、User、Term 的樣板 Views ○ 用 Clone 代替 Add
  • 10. 各種不同的樣板簡介 ● 常用的大致分成兩類: ○ list 型:撈出一群 Entity ○ id 型:撈出特定 id / name 的 Entity(常配合 Panels 做該 Entity View 的預設顯示方式的改寫)   ● 命名方式:_Entity Type(_list) ○ 以 Node 來說,就有 _node_list 跟 _node 兩種   ● 在管理上,若需要的 Views 不多,也可以只做 list 型的樣板   
  • 11. Node List 樣板(_node_list) ● Filters ○ Node: Published = Yes ○ Node: Type = Unknown ○ Node transaltion: Content negotiation(多語系專用)   ● Sort criteria ○ Node: post date = desc   ● Fields ○ Node: nid(隱藏、非連結、不要有千分位的逗號) ○ Node: Title(做成連結)
  • 12. Node 樣板(_node) ● 除了跟 Node List 樣板一樣的設定外,再加上底下的設定   ●  Argument ○ Node: Nid    ● Use Pager: 1 item
  • 13. Term List 樣板(_term_list) ● Filters ○ Taxonomy: Vocabulary = Unknown   ● Sort criteria ○ Taxonomy: Weight = asc   ● Fields ○ Taxonomy: Term ID(隱藏、非連結、不要有千分位的逗 號) ○ Taxonomy: Term(做成連結)
  • 14. Term 樣板(_term) ● 除了跟 Term List 樣板一樣的設定外,再加上底下的設定   ●  Argument ○ Taxonomy: Term ID   ● Use Pager: 1 item
  • 15. User List 樣板(_user_list) ● Filters ○ User: Active = Yes ○ User: Roles = Unknown   ● Sort criteria ○ User: Created date = desc   ● Fields ○ User: Uid(隱藏、非連結、不要有千分位的逗號) ○ User: Name(做成連結)
  • 16. User 樣板(_user) ● 除了跟 User List 樣板一樣的設定外,再加上底下的設定   ●  Argument ○ User: Uid   ● Use Pager: 1 item
  • 17. Views 裏面你該知道的三個函數 ● views_embed_view($name, $display_id = 'default') ○ 取得某個 Views 的執行結果(輸出)   ● views_get_view_result($name, $display_id = NULL) ○ 取得某個 Views 的執行結果(陣列)    ● 參數說明 ○ $name: Views 的名稱 ○ $display_id: Display 的名稱 ○ 第三個參數以後是要傳進該 Views 的參數
  • 18. Views 裏面你該知道的三個函數 ● views_get_view($name, $reset = FALSE) ○ $name: Views 的名稱 ○ $reset: 重新從資料庫中載入 Views 的設定
  • 19. 取得某個 Views 執行結果的(總)列數 ● 取得執行結果的列數 Count(views_get_view_result($name, $display_id));   ● 取得執行結果的總列數     $view = views_get_view($name);     $view->get_total_rows = true;     $view->execute($display_id);     $count = $view->total_rows;
  • 20. 兩個常用的 Views 模組 ● Embed Views Display ○ 非特定用途的 Views Display ○ 常配合 Panels 和 Customfield: PHP code 來組合資訊   ●  Views Custom Field ○ Customfield: Markup 類似 Global: Custom text ○ Customfield: PHP code 可在欄位中插入 PHP 程式碼 ○ Customfield: Rownumber 提供欄位項次資訊
  • 21. Attachment Display v.s. Customfield: PHP code ● Attachment Display 的限制 ○ 需在同一個 Views 裡面 ○ 傳入的參數要一致 ○ 無法在欄位層次混排資訊   ● 替代方案:Customfield: PHP code + views_embed_view ○ 可以取用不同 Views 的 Display ○ 傳入的參數可以不同(只要傳的是正確的就行) ○ 可配合 Global: Custom text 達成欄位層次的混排 ○ 可以有複雜的顯示條件
  • 22. 複雜的 Views 欄位排版技巧 1. 把需要的欄位加入欄位設定中 2. 設定好這些欄位的顯示樣式 3. 將這些欄位排除在顯示之外 4. 最後加入 Global: Custom text ,寫出合適的 HTML 結構 5. 配合 CCS 把版面做出來