View source
<?php
function image_attach_views_data() {
$data = array();
$data['image_attach']['table']['group'] = t('Image attach');
$data['image_attach']['table']['join'] = array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
'type' => 'LEFT',
),
);
$data['image_attach']['iid'] = array(
'title' => t('Attached images'),
'help' => t('The images attached to a node.'),
'relationship' => array(
'title' => t('Attached image nodes'),
'label' => t('Attached images'),
'help' => t('The image nodes attached to the given node. May produce multiple rows. To filter out nodes with no attached images, set this relationship to be required.'),
'base' => 'node',
'base field' => 'nid',
'relationship table' => 'image_attach',
'relationship field' => 'iid',
'handler' => 'views_handler_relationship',
),
);
$data['image_attach_reverse']['table']['group'] = t('Image attach');
$data['image_attach_reverse']['table']['join'] = array(
'node' => array(
'table' => 'image_attach',
'left_field' => 'nid',
'field' => 'iid',
'type' => 'LEFT',
),
);
$data['image_attach_reverse']['nid'] = array(
'title' => t('Attaching nodes'),
'help' => t('The nodes that have attached images.'),
'relationship' => array(
'title' => t('Attaching nodes'),
'label' => t('Attaching nodes'),
'help' => t("The nodes that have attached images. This relationship should be used on a view of image nodes, to get to their attaching 'parent' nodes."),
'base' => 'node',
'base field' => 'nid',
'relationship table' => 'image_attach_reverse',
'relationship field' => 'nid',
'handler' => 'views_handler_relationship',
),
);
return $data;
}
function image_attach_views_data_alter(&$data) {
$data['node']['image_attach_images'] = array(
'group' => t('Image attach'),
'field' => array(
'title' => t('Attached images'),
'help' => t('The attached images, shown at a chosen size. This field can be added without a relationship.'),
'handler' => 'image_attach_views_handler_field_attached_images',
),
);
}
function image_attach_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'image_attach'),
),
'handlers' => array(
'image_attach_views_handler_field_attached_images' => array(
'parent' => 'image_handler_field_image_node_image',
),
),
);
}