Make authorship available as a field in Views

Matt B - June 27, 2007 - 20:44
Project:Authorship Module
Version:5.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I use the Views module on my site and need to show the Authorship field in the views. Adding the following function to authorship.module and clearing the Views cache did the trick!

function authorship_views_tables() {
$tables['node_authorship'] = array(
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'nid',
),
'right' => array(
'field' => 'nid',
),
),
'fields' => array(
'authorship' => array(
'name' => t('Node: Authorship'),
'sortable' => true,
'help' => t('Display the authorship display setting for the node.'),
),
),
'sorts' => array(
'authorship' => array(
'name' => t('Node: Authorship'),
'help' => t('Sort by the node authorship, alphabetically'),
),
),
'filters' => array(
'authorship' => array(
'name' => t('Node: Authorship'),
'help' => t('Sort by the node authorship, alphabetically'),
),
),
);

return $tables;
}

Hope this is of use...

Matt

#1

AjK - June 28, 2007 - 01:11
Status:active» patch (code needs review)

#2

Matt B - June 28, 2007 - 05:41

Filters was not working - the following correction allows filetering on authorship:

'filters' => array(
'authorship' => array(
'name' => t('Node: Authorship'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
'help' => t('Sort by the node authorship, alphabetically'),
),
),

#3

AjK - June 29, 2007 - 11:06
Status:patch (code needs review)» fixed

Committed to Drupal-5 branch, thanks! : http://drupal.org/cvs?commit=71826

#4

Anonymous - July 13, 2007 - 11:16
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.