views

2012 年 project III http://business-services.scmp.com/

Snapshot: 

2012 年 project III (project II 仍然為內部使用中)

第一個我製作的使用 Drupal 7.x 的網站
集團內第一個 7.x 網站

因為是第一次使用 7.x 開發
功能上沒有要超越過去的功能的意思
志在將過去在 6.x 的經驗轉移到 7.x 的平台上
還好有這個決定, 否則可能真的會趕不上

一般的設定, 例如 cck都沒有太大的問題
介面都很類似
views 的介面上雖然類似, 但要細心使用額外的功能的話還是要花點時間適應
特別是處理輸出 html 的時候更明顯
新增的 field.tpl.php 和 views 的 field template 時有沖突
處理 node.tpl.php 的時候要細心開始吸收 entity 的概念和 API
再加上為 solr 所用的客制欄位等等

Rules 7.x 模組 201「當一內容設為 sticky 的時候, 站內其他的內容都設為 非 sticky」

首先介紹這個教學會用到的另一個強力模組: Views Bulk Operations
Views bulk operation (VBO) 是在 Drupal 6.x 的時候已經是很好用的模組
可以一次性為大量節點設定值
例如設為 unpublish, 批量賦與欄位值, 加減 tag 之類

VBO 在 7.x 的重大改變是它變成一個欄位
不再是一個獨立的 "Display"
可以想像, 建立一個 table, 再在前頭加一個 checkbox 欄位
table 的上方放一個 actions 的下拉選單

因為 views 是不支持 Rules 內的 "List" 的
所以便借用 VBO 的 "Load a list of entity objects from a VBO View."
將 "list of nodes" 傳到 rules 之內
所以, 相同原則之下, 你可以使用 node smart queue 逹成同樣的效果
VBO 只是一個例子而已

Views3 的 templates 選項

Views 3.x 的介面雖然和 views 2.x 有點相似 但便使用了更多的 DHTML, AJAX 技術 之前有網友說找不到 views 3.x templates suggestion 的選項 我截了些圖給大家參考:

Views List

Views Edit

Views Edit Advanced

Development Tips: strip html tags on Drupal like view's doing

-
Free tags: 

Views 的 fields 輸出項目有一個很方便的功能
它可以指定輸出一大段文字中的首 x 個字符
輸出 body 的時候可以大約控制欄位的長闊
實作原來是使用了 Drupal api:
http://api.drupal.org/api/drupal/modules--filter--filter.module/function...

因為 body 會自動插入 <p>
使用一般的 trim() 的話便會有 invalidate HTML 的問題
在 IE 上的版位便會變得更難控制了..

#IEhell

Updating views fields changes field alias names

When views is using fields as output,
you can hidden the field, and echo them in other field templates
you will get an alias, but that alias is willing to change.
So you cannot hardcode that in tpl files.

In order to retrieve the alias and its value:

Views 過濾列表預設不返回結果 Views exposed filter default show zero result

Show No Results by Default

原理是使用 Global argument
如果 filter 的返回值都是預設值的話, 用 argument 返回 false,
再輸出 empty text 或者不輸出值

arguments: Global Null
provide default argument
fixed entry
PHP Code:

Pages

Google