drupal - hook_views_handlers 没有被调用

标签 drupal drupal-7 drupal-views

我的 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/

相关文章:

drupal - 是否可以保存没有字段的 Drupal View ?

php - 如何让 PagerDefault 查询与 Drupal 7 一起正常工作?

php - 单元测试和普通测试有什么区别?

drupal - 在自定义 View 上使用节点摘要

jquery - 有没有办法从 drupal 上的 ctools 模态窗口中删除/或编辑关闭按钮?

php - 如何覆盖 drupal View 寻呼机查询?

drupal-7 - Drupal 7 View 页面中匿名用户不显示附加文件

php - php 和 mysql 的查询限制问题(drupal 6)

css - 将 <div> 与图像右侧对齐

php - 如何在 drupal 7 中定义模块级变量