基本上我想創建一個自定義處理程序來反序列化一個名爲birthday的db字段。無法爲Views2創建自定義處理程序
我已經設法正確輸出使用默認views_handler_field序列化的字段。不幸的是,當我嘗試創建自定義處理程序時,我收到以下消息:
錯誤:drappsprofiles處理程序>生日不存在!
這裏的文件結構:
all/modules/drapps/drappsprofile/
|->drappsprofiles.views.inc
|->drappsprofiles.module
|->drappsprofiles.install
|->drappsprofiles.info
|->drappsprofiles.inc
|->drappsprofiles_handler_field_birthday.inc
這裏的drappsprofiles.module
/**
* VIEWS2 MODULE
* Implementation hook_views_api
**/
function drappsprofiles_views_api() {
$info['api'] = 2;
return $info;
}
/*****************************************************************************
* INCLUDES
**/
// Loads Google Apps Profile Integration
module_load_include('inc', 'drappsprofiles');
(...)
這裏的drappsprofiles.views.inc
/**
*
* Implementation of hook_views_handlers().
*
**/
function drappsprofiles_views_handlers() {
return array(
'handlers' => array(
'drappsprofiles_handler_field_birthday' => array(
'parent' => 'views_handler_field',
)
)
);
}
/**
* Implementation of hook_views_data().
*
* @return array
**/
function drappsprofiles_views_data() {
(...)
$data['drappsprofiles']['birthday'] = array(
'title' => t('Birthday'),
'help' => t('Users birthday'),
'field' => array(
'handler' => 'drappsprofiles_handler_field_birthday',
'click sortable' => FALSE,
),
);
return $data;
}
drappsprofiles_handler_field_birthday.inc
<?php
/**
*
* Custom views handler for Birthday
*
*/
class drappsprofiles_handler_field_birthday extends views_handler_field {
function render($values) {
$val = unserialize($values->{$this->field_alias});
return ($val);
}
}
似乎drappsprofiles_handler_field_birthday.inc沒有被讀取,但我無法弄清楚爲什麼。
任何幫助,將不勝感激。 (我一直在圍繞這2個星期!)
感謝您的回答。我剛纔解決了這個問題,就像你提出的那樣,卸載並重新安裝。奇怪,但它的工作。 – Tivie 2011-06-05 22:15:51