基本上我想创建一个自定义处理程序来反序列化一个名为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