Trước khi tìm hiểu những hook bắt buộc phải biết một Field type gồm những thành phần nào, theo kiến trúc của Field API thì một Field type gồm 3 thành phần chính:
Vậy khi viết một Field type mới cần bắt buộc các hook sau đây:
Khi nâng cấp Drupal 7 từ phiên bản Alpha 5 lên phiên bản Alpha 6 cần chú ý các vấn đề sau:
Cài Drupal xong cài tiếp 2 module trên
Thông thường sau mỗi lần nâng cấp module mới trong Drupal, thì cơ sở dữ liệu sẽ bị thay đổi do nhu cầu thiết kế. Nên Drupal xây dựng một hook để hổ trợ việc update cơ sở dữ liệu khi có nhu cầu nâng cấp module. Hook đó có tên là hook_update_N.
Hook này được gọi mỗi khi chạy file update.php ở thư mục gốc của site, ví dụ http://www.example.com/update.php. Trong hook này có kí tự N đại diện cho chữ số. Chữ số này có cấu trúc XYZZ gồm 3 phần sau: X, Y và ZZ
<?php
function _drupal_bootstrap($phase) {
global $conf;
switch ($phase) {
case DRUPAL_BOOTSTRAP_CONFIGURATION:
drupal_unset_globals();
// Start a page timer:
timer_start('page');
// Initialize the configuration
conf_init();
break;
case DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE:
// Allow specifying special cache handlers in settings.php, like
// using memcached or files for storing cache information.
require_once variable_get('cache_inc', './includes/cache.inc');
// If the page_cache_fastpath is set to TRUE in settings.php and
// page_cache_fastpath (implemented in the special implementation of
// cache.inc) printed the page and indicated this with a returned TRUE
// then we are done.
if (variable_get('page_cache_fastpath', FALSE) && page_cache_fastpath()) {
exit;
}
break;
?>
Recent blog posts
Old CSS ID (Drupal 6): block-blog-0
New CSS ID (Drupal 7): block-blog-recent
Book navigation
Old CSS ID (Drupal 6): block-book-0
New CSS ID (Drupal 7): block-book-navigation
Recent comments
Old CSS ID (Drupal 6): block-comment-0
New CSS ID (Drupal 7): block-comment-recent
Active forum topics
Old CSS ID (Drupal 6): block-forum-0
New CSS ID (Drupal 7): block-forum-active
New forum topics
Old CSS ID (Drupal 6): block-forum-1
Trong file settings.php của website1.com
<?php
$db_url = 'mysql://username:password@localhost/db_website1';
$db_prefix = array(
'default' => 'w1_',