Drupal Planet

CCK fields hook_form_alter CCK 欄位的修改

如果大家一直都有看我的 blog
相信都對使用 hook_form_alter() 很熟識
修改, 新增各種說明文字是小菜
將整個表單完全改頭換成志玲一樣美都沒有難度

這次是修改 CCK 的欄位
一個日期的欄位, 只是很簡單的需要多一點說明的文字,
再組合兩個日期
但我發覺 hook_form_alter 的 $form是沒有 CCK 的欄位的
因為 form API 的流程還沒有經過 CCK
所以需要延後處理$form
form API 的 #after_build 正是為這而設

Drupal Camp Taipei 2011 presentation

-
Free tags: 

Here I pre-release my presentation notes, please come to my presentation at 13:00 at track2!! http://goo.gl/9LdZm #drupalCampTaipei2011

Boost cache module health and tips

Boost cache module 是我常用的提升效能的模組
好處是搭建簡單, 幾乎能使用 Drupal 的環境都可以使用
也不需要 shell 的權根
但效能上沒有 vanish 的好

關於 boost 的效能, 最重要的是正確的 cron job
正確的cron 可以確保 boost 產生的檔案和資料夾在過期的情況之下清走
否則 cache 資料夾內的檔案數量很快會直線增加
反倒拖慢了網站

cron 的運行密度起碼需要和 boost 的 expire time 一致
甚至更短
例如本站的 cache 是 1小時 expire, cron 是15分鐘

其餘比較重要的是
Clear all empty folders from cache
和時常留意 "Clear Boost expire data: X page" 的數字
我也有見過 250K PV/m 的網站仍可以使用 boost 的

form 也可以使用template (*.tpl.php) (Drupal6.x 版)

舊文:
http://www.joetsuihk.com/form_templates
的做法不太正統, 應該要改成: (用 user-login form 為例):

theme 的 template.php 之內:

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:

2011-03-30 HKDUG meeting presentation (Hong Kong Drupal User Group Meeting)

On 2011-03-30, at Tunner's office, I presented the way I build image gallery, as requested from last time's meeting. Enjoy, feedback welcomed!

https://docs.google.com/present/view?id=d4qrhzr_179ntv4brhb

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:

2011年 2月 25日 Drupal.org Git migration 和 Windows 下的 Git 教學

萬眾祈待, Drupal.org Git 上線了! DEMO: http://drupalcode.org/project/tabbed_block.git

教學: Windows 下使用 Git (只有最基本的功能, 慢慢再增加進階功能)

  1. 安裝 Git 客戶端

改變 form 的 template

這次修改的是 views 的 exposed form
需要比較大的修改便想要使用 tpl 而不使用 template.php
舊文 form 也可以使用template (*.tpl.php)也有說明, 但已經不是 Drupal6.x 作法了

以下更新為 Drupal6.x 的作法:
先自建一個模組, 使用 hook_theme
定義如下:

查找一個選單的欄位的可選項 Get display values of a dropdown list

在 views 的 $views->exposed filter 可以提取已經提交的表單值
但除了值之外, 一般還需要欄位的其他資料,
例如欄位旳值和顯示值不一樣的時候,

可以使用:

Google