基本的に、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週間行っています!)