I need help on a [module]_views.inc declaration...
First, the summary :
I have three tables : nodes, content_watcho_picture and watcho_picture.
- picture table is a content-type table with following informations : nid, wpid (same as nid), fid, owner.
- content_watcho_picture is a "related" table, which store relations between a node (ie: an album) and one or multiple watcho_picture node(s). fields are following :
-- nid : master node id
-- wpid : watcho_picture nid
-- delta : weight of the picture in the master node (to order pictures)
node.nid => content_watcho_picture.nid
content_watcho_picture.wpid => watcho_picture.nid (or wpid, twice are same).
My goal is the following : I want to create a view with nid argument (an album nid) and get all watcho_pictures attached to this album. BUT, because there is a "but"... But I would like to specify for example : use ajax : TRUE, use pager : TRUE, items to display : 12.
Actually, I can retrieve all pictures from a specific node, but there is no page, because the pager is specified on the album nid... There is only one album, also the pager isn't displayed...
I have tried many different combination in my [module]_views.inc but don't get the correct way to retrieve all pictures and get a pager for the next pictures displayed...
This is my actual hook_views_data declaration :
function watcho_picture_views_data() {
// Basic table information.
// ----------------------------------------------------------------
$data['watcho_picture']['table']['group'] = t('Picture');
$data['watcho_picture']['table']['base'] = array(
'field' => 'nid',
'title' => t('Picture'),
'help' => t('Picture uploaded by uploadify field'),
);
$data['watcho_picture']['table']['join'] = array(
'node' => array(
'left_table' => 'content_watcho_picture',
'left_field' => 'nid',
'field' => 'nid',
'type' => 'INNER',
),
'content_watcho_picture' => array(
'left_field' => 'wpid',
'field' => 'wpid',
),
);
$data['watcho_picture']['wpid'] = array(
'title' => t('wpid'),
'help' => t('The id of the picture.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['watcho_picture']['fid'] = array(
'title' => t('file id'),
'help' => t('The file id of the picture.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['content_watcho_picture']['table']['group'] = t( 'Picture');
$data['content_watcho_picture']['table']['join'] = array(
'watcho_picture' => array(
'left_field' => 'wpid',
'field' => 'wpid',
),
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
'type' => 'INNER',
),
);
$data['content_watcho_picture']['wpid'] = array(
'title' => t('Picture'),
'help' => t('Get all pictures node related with the current node.'),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'watcho_picture',
'base field' => 'wpid',
'label' => t('watcho picture'),
),
);
$data['content_watcho_picture']['picture'] = array(
'title' => t('Picture'),
'help' => t('The picture itself.'),
'field' => array(
'handler' => 'views_handler_field_picture',
),
);
$data['content_watcho_picture']['delta'] = array(
'title' => t('Delta'),
'help' => t('The delta of picture.'),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
return $data;
}
And the query executed is the following :
SELECT node.nid AS nid,
watcho_picture_content_watcho_picture__content_watcho_picture.wpid AS watcho_picture_content_watcho_picture__content_watcho_picture_wpid,
watcho_picture_content_watcho_picture__content_watcho_picture.delta AS watcho_picture_content_watcho_picture__content_watcho_picture_delta
FROM node node
INNER JOIN content_watcho_picture content_watcho_picture
ON node.nid = content_watcho_picture.nid
LEFT JOIN watcho_picture watcho_picture_content_watcho_picture
ON content_watcho_picture.wpid = watcho_picture_content_watcho_picture.wpid
LEFT JOIN content_watcho_picture watcho_picture_content_watcho_picture__content_watcho_picture
ON watcho_picture_content_watcho_picture.wpid = watcho_picture_content_watcho_picture__content_watcho_picture.wpid
WHERE (node.nid = 118947 )
ORDER BY watcho_picture_content_watcho_picture__content_watcho_picture_delta ASC
I think I'm near a solution, but I don't find the good way to achieve my declaration and get the pager working correctly...
Please, any help would be really appreciated.
Thanks in advance for your suggestions and remarks.