利用 drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的...

26
利利 Drupal 利利利利利利利利利利利利

Upload: oswald-elliott

Post on 13-Jan-2016

254 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

利用 Drupal 建構豐富的內容與資訊彙整

Page 2: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

outline

• 客制化 content type– 我的 del.icio.us !– 客制化 Layout– 更豐富的內容

• 提昇 Drupal CMS 的語意• My Page – 資訊彙整

Page 3: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

客制化 content type• 透過 CCK (Content Construction Kit)

以及相關模組來擴充。• 相關模組:

– Address Field for CCK– CCK Field Permissions– CCK Freetagger– Feedfield– … 約 60 種。

Page 4: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

安裝 CCK 與相關模組• 備份資料庫與 code ( 見我寫的 BATCH)• 首先安裝 CCK 模組

– 將 cck-5.x-1.5.tar.gz 解壓縮至 modules 目錄下

– 利用 id=1 的管理者身份進入 Administrator > Site Building > Modules 勾選 checkbox 啟用

– CCK 為 Drupal 5.1 Core Module

• Content Construction Kit Handbook at http://drupal.org/node/101723

• 祈禱~

Page 5: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

備份小程式REM @ECHO OFF

FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%AFOR /F "TOKENS=1,2 eol=/ DELIMS=/" %%A IN ('DATE/T') DO SET mm

=%%BFOR /F "TOKENS=2,3 DELIMS=/" %%A IN ('echo %CDATE%') DO SET dd

=%%BFOR /F "TOKENS=1,2 eol=/ DELIMS=/" %%A IN ('DATE/T') DO SET yy

yy=%%A

"C:\Program Files\xampp\mysql\bin\mysqldump.exe" -uroot –p**** drupal_db > D:\drupal_db_%yyyy%-%mm%-%dd%.sql

"C:\Program Files\WinRAR\Rar.exe" a D:\toolsBkup\db_bkup\drupal_db_%yyyy%-%mm%-%dd%.rar D:\drupal_db_%yyyy%-%mm%-%dd%.sql

del D:\drupal_db_%yyyy%-%mm%-%dd%.sql

REM "C:\Program Files\WinRAR\Rar.exe" a D:\toolsBkup\db_bkup\drupal_%yyyy%-%mm%-%dd%.rar "C:\Program Files\xampp\htdocs\drupal"

Page 6: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

出現警告或錯誤的情況

Page 7: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

How to Troubleshoot!

• Stop and Think• Read the errors• Validate your page• Read the README• Search the right way• Identify the source of the problem• Dump some diagnostics• Ask the right questions• Identify the module that's giving you problems

Page 8: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Social Bookmark: del.icio.us

Page 9: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

我的 del.icio.us !• 需要安裝的模組:

– CCK– Link– Views

• Content Type:– 新增一個 content type social bookmark

• Views:– 新增一個 page view 與 block– Tutorial: http://drupal.org/node/59157

• 原則: Nodes holds content, views save queries.

Page 10: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

新增一個 content type: social bookmark

Page 11: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

編輯所需要的 field

Page 12: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Views 設定 – Basic Information

Page 13: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Views 設定 – Page

Page 14: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Views 設定 – Block

Page 15: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Views 設定 – Fields

Page 16: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Views 設定 – Filter and Sort

Page 17: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Views 完成

Page 18: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

心得• 醜• Module 管理功能• Views 掌管部份輸出• Node 保存資源• 無須寫 code!

Page 19: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Template Structure

Page 20: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

Template 命名規則與變數意義• page-node-edit.tpl.php• page-node-1.tpl.php• page-node.tpl.php• page.tpl.php

• node-nodetype.tpl.php• node.tpl.php

• block-modulename-delta.tpl.php• block-modulename.tpl.php• block-region.tpl.php• block.tpl.php

• <page>– $base_path– $closure– $css– $content– ...

• <node>– $content– $node– $date– $links– ...

• <block>– $block– $block_id– $block_zebra– ...

• 請讀 Pro_Drupal_Developement p.115 - 122 或善用函式 print_r

Page 21: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意
Page 22: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

stdClass Object( [nid] => 1227 [vid] => 1256 [type] => bookmark [status] => 1 [created] => 1182318999 [changed] => 1182318999 [comment] => 2 [promote] => 0 [sticky] => 0 [revision_timestamp] => 1182318999 [title] => Drupal 官網 [teaser] => <div class="field field-type-link field-field--url"><div class="field-label"> 書籤 :<

/div><div class="field-items"><div class="field-item"><a href="http://drupal.org" target="_blank">http://drupal.org</a></div></div></div><p>Drupal 好耶! </p>

[log] => [format] => 1 [uid] => 14 [name] => bluce [picture] => files/pictures/picture-14.jpg [data] => a:10:{s:9:"user_msnm";s:0:"";s:16:"privatemsg_allow";i:1;s:9:"interests";s:0:"";s:2

8:"privatemsg_setmessage_notify";i:1;s:20:"privatemsg_mailalert";i:1;s:14:"tinymce_status";s:5:"false";s:7:"contact";i:1;s:8:"og_email";s:1:"2";s:5:"block";a:1:{s:9:"tagadelic";a:1:{i:2;i:1;}}s:14:"picture_delete";s:0:"";}

[field__url] => Array ( [0] => Array ( [url] => http://drupal.org [title] => [attributes] => N; [view] => <a href="http://drupal.org" target="_blank">http://drupal.org</a> )

)

[0] => Array…

Hmm, MVC 做的不太好!

Page 23: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

My Review!• 需要安裝的模組:

– CCK– Link– Views– ImageField– Neighborhood CCK– VotingAPI– Fivestar– pdfview

• Content Type:– 新增一個 content type my_review

• Views:– 新增一個 page view 與 block

Page 24: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意
Page 25: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意

為 Drupal CMS 加入語意• RSS

• SIOC

• FOAF

• vCard

Page 26: 利用 Drupal 建構豐富的內容與 資訊彙整. outline 客制化 content type – 我的 del.icio.us ! – 客制化 Layout – 更豐富的內容 提昇 Drupal CMS 的語意