基本上,我想创建一个自定义处理程序来反序列化一个名为birthday的db字段。
我已经设法正确地输出了使用默认views_handler_field序列化的字段。不幸的是,当我尝试创建自定义处理程序时,我收到以下消息:
错误:drappsprofile>生日的处理程序不存在!
下面是文件结构:
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似乎没有被读取,尽管我找不出原因。
任何帮助都将不胜感激。(我在这方面已经有两个星期了!)
发布于 2011-06-05 05:24:29
假设你的(...)在.views.inc中隐藏如下代码:
$data['drappsprofiles']['table']['group'] = t('drappsprofiles');
$data['drappsprofiles']['table']['base'] = array(
'field' => 'birthday',
);
$data['drappsprofiles']['table']['join'] = array(
'#global' => array(),
);我假设它是这样的,因为您的字段有一个可供选择的组,以便它可以查找缺少的处理程序。
那么接下来要看的仍然是module_views_handlers()中的.views.inc {:
return array(
++ 'info' => array(
++ 'path' => drupal_get_path('module','drappsprofilse'),
++ ),
'handlers' => array(除此之外,我不想这么说,但卸载并重新安装模块显然会刷新.views.inc的最新代码调整。我知道我有很多次,你可能也注意到了这一点。
https://stackoverflow.com/questions/5958178
复制相似问题