Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've read that it's possible to add another field to the table which counts the images in each album.
Anyone who has managed to do that and could share their work? I'm really lost on if I have to add the computed field to the galleri-node or image-node and how to calculate the relation between them..
This is my current view:
$view = new view;
$view->name = 'galleries_listing';
$view->description = 'A page view displaying teasers of all existing galleries.';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Gallery page (list of galleries)', 'default');
$handler->override_option('relationships', array(
'field_gallery_nid' => array(
'label' => 'Gallery',
'required' => 0,
'delta' => -1,
'id' => 'field_gallery_nid',
'table' => 'node_data_field_gallery',
'field' => 'field_gallery_nid',
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'name' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_taxonomy' => 0,
'exclude' => 1,
'id' => 'name',
'table' => 'term_data',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'field_gallery_nid',
),
'field_gallery_image_fid' => array(
'label' => 'Siste bilde',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'custom',
'format' => 'imagefield__lightbox2__gallery_last_image__original',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_gallery_image_fid',
'table' => 'node_data_field_gallery_image',
'field' => 'field_gallery_image_fid',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'exclude' => 1,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'override' => array(
'button' => 'Override',
),
'relationship' => 'field_gallery_nid',
),
'body' => array(
'label' => 'Album',
'alter' => array(
'alter_text' => 1,
'text' => '[title]<br />[body]',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'body',
'table' => 'node_revisions',
'field' => 'body',
'relationship' => 'field_gallery_nid',
),
'subject' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => 'Ingen kommentarer enda',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_comment' => 1,
'exclude' => 1,
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'last_comment_timestamp' => array(
'label' => 'Siste kommentar',
'alter' => array(
'alter_text' => 1,
'text' => '[subject]<br />
[last_comment_timestamp]',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'date_format' => 'time ago',
'custom_date_format' => '',
'exclude' => 0,
'id' => 'last_comment_timestamp',
'table' => 'node_comment_statistics',
'field' => 'last_comment_timestamp',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('sorts', array(
'title' => array(
'order' => 'ASC',
'id' => 'title',
'table' => 'node',
'field' => 'title',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status_extra' => array(
'operator' => '=',
'value' => '',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'gallery_image' => 'gallery_image',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => 'name',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'title' => 'title',
'name' => 'name',
),
'info' => array(
'title' => array(
'sortable' => 0,
'separator' => '',
),
'name' => array(
'sortable' => 0,
'separator' => '',
),
),
'default' => '-1',
));
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'relationship' => 'none',
'build_mode' => 'teaser',
'links' => 1,
'comments' => 0,
));
Comments
Comment #1
yannickooAny news to count the images?