[support] Views Handler Help - Please
Ms. Nancy Wichmann
nan_wich at bellsouth.net
Tue Jun 5 15:25:59 UTC 2012
I am trying to get a Views (2) handler to work and I don't have enough hair left to continue pulling it out.
In my module file:
/**
* Implements hook_views_api().
*/
function mymodule_views_api() {
return array(
'api' => '2.0',
'path' => drupal_get_path('module', 'mymodule') /*. '/views'*/,
);
}
/**
* Implements hook_views_handlers().
*/
function mymodule_views_handlers() {
return array('handlers' => array('mymodule_views_handler_field_age_flag'));
}
In mymodule_views.inc (same directory as .module):
/**
* Implementation of hook_views_data_alter().
* Add "NEW" flag to nodes that are 30 days or less old.
*/
function mymodule_views_data_alter(&$data) {
// Make sure field names are unique or they may override
// standard node fields.
$data['node']['age_flag'] = array(
'title' => t('Age flag'),
'help' => t('Flag to indicate the age of a Node.'),
'field' => array(
'handler' => 'mymodule_views_handler_field_age_flag',
'group' => 'Node',
'click sortable' => FALSE,
),
);
}
So far, so good. The field does show up as selectable. But it keeps saying that the node > age_flag handler cannot be found".
I have added the file to the module's .info files[] - no help. I have tried placing the handler in the same directory as the module, and both an "includes" and "views" directories. No help.
The handler file itself:
/**
* class definition.
*/
class mymodule_views_handler_field_age_flag extends views_handler_field {
/**
* Render function: return html output
* Including edit and delete action
*/
function render($values) {
// See if the created date is less than 30 days ago.
$ret = NULL;
if ($values->created - REQUEST_TIME < 2592000) {
$ret = 'NEW';
}
return $ret;
}
/**
* class query.
*/
function query() {
// Do nothing, leave query blank, we render the contents
}
}
What am I doing stupid that makes Views not find this handler? And yes, I am clearing the Views cache and the Drupal caches every time I blink my eyes.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120605/20622568/attachment.html
More information about the support
mailing list