首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法为Views2创建自定义处理程序

无法为Views2创建自定义处理程序
EN

Stack Overflow用户
提问于 2011-05-11 09:17:07
回答 1查看 292关注 0票数 0

基本上,我想创建一个自定义处理程序来反序列化一个名为birthday的db字段。

我已经设法正确地输出了使用默认views_handler_field序列化的字段。不幸的是,当我尝试创建自定义处理程序时,我收到以下消息:

错误:drappsprofile>生日的处理程序不存在!

下面是文件结构:

代码语言:javascript
复制
all/modules/drapps/drappsprofile/
  |->drappsprofiles.views.inc
  |->drappsprofiles.module
  |->drappsprofiles.install
  |->drappsprofiles.info
  |->drappsprofiles.inc
  |->drappsprofiles_handler_field_birthday.inc

这是drappsprofiles.module

代码语言:javascript
复制
/**
 * 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

代码语言:javascript
复制
/**
 *
 * 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

代码语言:javascript
复制
<?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似乎没有被读取,尽管我找不出原因。

任何帮助都将不胜感激。(我在这方面已经有两个星期了!)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-05 05:24:29

假设你的(...)在.views.inc中隐藏如下代码:

代码语言:javascript
复制
  $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 {:

代码语言:javascript
复制
  return array(
++  'info' => array(
++    'path' => drupal_get_path('module','drappsprofilse'),
++    ),
     'handlers' => array(

除此之外,我不想这么说,但卸载并重新安装模块显然会刷新.views.inc的最新代码调整。我知道我有很多次,你可能也注意到了这一点。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5958178

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档