# load temporary_list settings for user and ou:
$self->_load_lists_and_settings if ($ctx->{user});
+ # fetch metarecord constituent counts for display
+ my $mr_counts = [];
+ if ($is_meta) {
+ $mr_counts = $e->json_query({
+ select => {mmrsm => [{
+ column => 'id', transform => 'count',
+ alias => 'count', aggregate => 1
+ }, 'metarecord'
+ ]},
+ from => 'mmrsm',
+ where => {'+mmrsm' => {metarecord => $rec_ids}}
+ });
+ }
+
# shove recs into context in search results order
for my $rec_id (@$rec_ids) {
my ($rec) = grep { $_->{$id_key} == $rec_id } @data;
$ctx->{metarecord_master} = $rec
if $metarecord_master and $metarecord_master eq $rec_id;
- # MR's with multiple constituent records will have a
- # null value in position 2 of the result set.
- my ($res_rec) = grep { $_->[0] == $rec_id} @{$results->{ids}};
- $rec->{mr_has_multi} = !$res_rec->[2];
+ if ($is_meta) {
+ # add the count of constituent records to the metarecord
+ my ($count) = grep {$_->{metarecord} == $rec_id} @$mr_counts;
+ $rec->{mr_constituent_count} = $count->{count};
+ }
}
if ($tag_circs) {
# note: rec.id refers to the record identifier, regardless
# of the type of record. i.e. rec.id = mmr_id ? mmr_id : bre_id
IF rec.mmr_id;
- IF rec.mr_has_multi;
+ IF rec.mr_constituent_count > 1;
# metarecords link to record list page
record_url = mkurl(ctx.opac_root _ '/results',
{metarecord => rec.mmr_id}, ['page']);
[% END %]
<a class='record_title search_link' name='record_[% rec.id %]'
href="[% record_url %]"
- [% html_text_attr('title', l('Display record details for "[_1]"', attrs.title)) %]
- >[% attrs.title | html %]</a>
+ [% html_text_attr('title', l('Display record details for "[_1]"', attrs.title)) %]>
+ [% attrs.title | html %]
+ </a>
+ [% IF rec.mr_constituent_count > 1 %]
+ <span title="[% l('This group contains [_1] records', rec.mr_constituent_count) %]">
+ ([% rec.mr_constituent_count %])
+ </span>
+ [% END %]
+
[%-
FOR entry IN attrs.graphic_titles;
FOR alt IN entry.graphic;