0

基本的に、birthdayというdbフィールドのシリアル化を解除するカスタムハンドラーを作成したいと思います。

デフォルトのviews_handler_fieldを使用してシリアル化されたフィールドを正しく出力することができました。残念ながら、カスタムハンドラーを作成しようとすると、次のメッセージが表示されます。

エラー:drappsprofiles>誕生日のハンドラーが存在しません!

ファイル構造は次のとおりです。

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');
(...)

ここにdrapsprofiles.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が読み取られていないようですが、理由はわかりません。

どんな助けでもいただければ幸いです。(私はこれを2週間行っています!)

4

1 に答える 1

1

.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に更新されるようです..私は何度もしなければならなかったことを知っています、おそらくこれにも気づいたでしょう。

于 2011-06-04T21:24:28.510 に答える