transition-7.x

list_allowed_values() taxonomy_allowed_values()

查找一個選單的欄位的可選項 Get display values of a dropdown list
Drupal 6 使用比較間接的方法才可以拿到 field 的所有可能值
而 Druapl 7 便可以使用 list_allowed_values()
完成相同的工作, example:

Drupal 7 field.tpl.php

-
Free tags: 

Fields 是其中一個 Drupal 7 最重要的改變
Title, body, image 都是 fields
可以想像為將 cck 的 "Manage Fields" 都變為 Drupal 核心的一部份
而且 node.tpl.php 之下還有一個 field.tpl.php
可以為某 field 獨立設定輸出 html

field.tpl.php 的原型可以在 modules/field/theme 內找到
一如 node.tpl.phph, field.tpl.php 也有多個 template suggestions
例如

templates 內的欄位值 field_get_items()

打開 node.tpl.php 的時候你便可以發現,
Drupal 7 的多語言支持轉移到以欄位為基礎
在預設的情況之下欄位值都放在 "und" 之內
代表沒有指定的語言
但如果代碼直接使用 und 的話
之後打開多語言設定便會令 templates 出現錯誤
所以便要使用 field_get_items() 來獲得正確的語言欄位值了

ref:
http://www.davereid.net/content/hlkd7fotw-field-get-items

6.x 到 7.x : hook_theme Drupal 7.x

等了一年多的時間, 終於有機會和時間可以正式使用 Drupal 7.x 作開發
所以都會集中一些 Drupal 7.x 和之前的不同之處
希望幫到大家, 也幫到自己

專用 tags: transition-7.x

hook_theme() 是一個很常用的 hook 之一
theme('image') 會調用 hook_theme()
以下的例子是自定義一個 theme 函數
輸出的是一整頁的 google map, 所以便使用一個新的函數
D7 的 函數參數只有兩個, hook 和 variables:

Google