function photos_views_data in Album Photos 8.4
Same name and namespace in other branches
- 7.3 inc/views/photos.views.inc \photos_views_data()
Implements hook_views_data().
File
- ./
photos.module, line 1577 - Implementation of photos.module.
Code
function photos_views_data() {
$data = [];
$data['photos_album'] = [];
$data['photos_album']['table'] = [];
$data['photos_album']['table']['group'] = t('Photos');
$data['photos_album']['table']['provider'] = 'photos';
// Join node_field_data.
$data['photos_album']['table']['join'] = [
'node_field_data' => [
'left_field' => 'nid',
'field' => 'pid',
],
'photos_image' => [
'left_field' => 'pid',
'field' => 'pid',
],
];
// File ID table field.
$data['photos_album']['fid'] = [
'title' => t('Album cover'),
'help' => t('The album cover image.'),
'field' => [
'id' => 'photos_image',
],
'sort' => [
'id' => 'standard',
],
'filter' => [
'id' => 'boolean',
'label' => t('Has cover'),
'type' => 'yes-no',
],
// Define a relationship to the {file_managed} table.
'relationship' => [
'id' => 'standard',
'base' => 'file_managed',
'entity type' => 'file',
'base field' => 'fid',
'label' => t('Cover'),
'title' => t('The cover associated with this album.'),
'help' => t('Access to the file associated with the cover of this Album.'),
],
];
// Album weight.
$data['photos_album']['wid'] = [
'title' => t('Album weight'),
'help' => t('The weight of this album.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
// Album image count.
$data['photos_album']['count'] = [
'title' => t('Album image count'),
'help' => t('The number of images in this album.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
$data['photos_image'] = [];
$data['photos_image']['table'] = [];
$data['photos_image']['table']['group'] = t('Photos');
$data['photos_image']['table']['provider'] = 'photos';
// Join album info to images.
$data['photos_image']['table']['join'] = [
'file_managed' => [
'left_field' => 'fid',
'field' => 'fid',
],
'node_field_data' => [
'left_field' => 'nid',
'field' => 'pid',
],
'photos_album' => [
'left_field' => 'pid',
'field' => 'pid',
],
];
// File ID table field.
$data['photos_image']['fid'] = [
'title' => t('Image'),
'help' => t('Album image.'),
'field' => [
'id' => 'photos_image',
],
'sort' => [
'id' => 'standard',
],
'relationship' => [
'id' => 'standard',
'base' => 'file_managed',
'entity type' => 'file',
'base field' => 'fid',
'label' => t('Image file'),
'title' => t('The file associated with this image.'),
'help' => t('Access to the file information associated with this image.'),
],
];
// Image title.
$data['photos_image']['title'] = [
'title' => t('Image title'),
'help' => t('The title for this image.'),
'field' => [
'id' => 'standard',
],
'sort' => [
'id' => 'standard',
],
'filter' => [
'id' => 'string',
],
];
// Image description.
$data['photos_image']['des'] = [
'title' => t('Image description'),
'help' => t('The description for this image.'),
'field' => [
'id' => 'standard',
],
'sort' => [
'id' => 'standard',
],
'filter' => [
'id' => 'string',
],
];
// Image weight.
$data['photos_image']['wid'] = [
'title' => t('Image weight'),
'help' => t('The image weight - custom sort order.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
// Image views count.
$data['photos_image']['count'] = [
'title' => t('Image views'),
'help' => t('Number of times this image has been viewed.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
// Image comment count.
$data['photos_image']['comcount'] = [
'title' => t('Image comments'),
'help' => t('Number of comments this image has.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
return $data;
}