我的hook_views_handlers()没有被调用。我尝试清除缓存,重新安装模块等。我添加了watchdog()调用以查看是否被调用,但从未执行过。
此字段使用相同的代码视图类型公开计数器:
我可以将字段添加到视图中,但是一旦添加,它就会显示为“残破/丢失”
所有这三个文件都位于funwithviews模块目录的根目录中。这是相关的代码。
有什么地方不对吗?
它存在于:funwithviews.module
/**
* Implements hook_views_api().
*/
function funwithviews_views_api() {
return array(
'api' => 3.0
);
}
它存在于:funwithviews.views.inc
/**
* Implementation of hook_views_data()
*/
function funwithviews_views_data() {
$data['fwv']['table']['group'] = t('FunSpace');
$data['fwv']['table']['join'] = array(
'#global' => array(),
);
$data['fwv']['counter'] = array(
'title' => t('Fun counter'),
'help' => t('This counter is more fun than the other one.'),
'field' => array(
'handler' => 'funwithviews_handler_field_fwv_counter',
),
);
return $data;
}
/**
* Implements of hook_views_handlers().
*/
function funwithviews_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'funwithviews'),
),
'handlers' => array(
'funwithviews_handler_field_fwv_counter' => array(
'parent' => 'views_handler_field',
),
),
);
}
它存在于:funwithviews_handler_field_fwv_counter.inc
class funwithviews_handler_field_fwv_counter extends views_handler_field {
最佳答案
是的,我认为必须将其添加到您的信息文件中,如视图本身所示:
http://drupalcode.org/project/views.git/blob/refs/heads/7.x-3.x:/views.info