我的 hook_views_handlers() 没有被调用。我尝试过清除缓存、重新安装模块等...我添加了 watchdog() 调用来查看它是否被调用,但它从未被调用。
此字段公开一个与代码 View 计数器使用的类型相同的计数器:
我可以将字段添加到 View 中,但添加后,它只会显示为“损坏/丢失”
所有这 3 个文件都位于 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 {
最佳答案
是的,您必须将其添加到您的信息文件中,我认为如 View 本身所示: http://drupalcode.org/project/views.git/blob/refs/heads/7.x-3.x:/views.info
关于drupal - hook_views_handlers 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9340017/