Bugzilla – Attachment 193730 Details for
Bug 14962
Temp Shelving Location / On Display Module
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14962: On Display code for OPAC scripts & templates
9f268cc.patch (text/plain), 16.23 KB, created by
Martin Renvoize (ashimema)
on 2026-02-24 13:35:43 UTC
(
hide
)
Description:
Bug 14962: On Display code for OPAC scripts & templates
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-24 13:35:43 UTC
Size:
16.23 KB
patch
obsolete
>From 9f268cc276c849e56eae7b3110032615451191b7 Mon Sep 17 00:00:00 2001 >From: Jake Deery <jake.deery@openfifth.co.uk> >Date: Mon, 1 Dec 2025 14:47:58 +0000 >Subject: [PATCH] Bug 14962: On Display code for OPAC scripts & templates > >This patch makes the necessary changes to the OPAC to make sure effective locations, collection codes, and branches are correctly displayed. >Please see the test files commit for instructions on how to test this bundle of patches. > >Sponsored-by: ByWater Solutions >Signed-of-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > .../bootstrap/en/modules/opac-basket.tt | 8 +- > .../bootstrap/en/modules/opac-detail.tt | 31 ++++++-- > opac/opac-detail.pl | 78 ++++++++++++++++--- > opac/opac-reserve.pl | 36 ++++++++- > 4 files changed, 133 insertions(+), 20 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt >index 382bf9727c3..01d4412f59c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt >@@ -319,7 +319,9 @@ > [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %] > <li> > <strong>[% Branches.GetName(ITEM_RESULT.holdingbranch) | html %]</strong> >- <span class="shelvingloc">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_RESULT.location, opac => 1 ) | html %]</span> >+ <span class="shelvingloc" >+ >[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_RESULT.effective_location, opac => 1 ) | html %]</span >+ > > [% IF ( ITEM_RESULT.itemcallnumber ) %] > ([% ITEM_RESULT.itemcallnumber | html %]) > [% END %] >@@ -401,7 +403,9 @@ > >[% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %] > <li> > [% Branches.GetName(ITEM_RESULT.holdingbranch) | html %] >- <span class="shelvingloc">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_RESULT.location, opac => 1 ) | html %]</span> >+ <span class="shelvingloc" >+ >[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_RESULT.effective_location, opac => 1 ) | html %]</span >+ > > <span class="ccode">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ITEM_RESULT.ccode, opac => 1 ) | html %]</span> > [% IF ( ITEM_RESULT.itemcallnumber ) %] > ([% ITEM_RESULT.itemcallnumber | html %]) >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index 9d432eaa075..46c90cf937c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1309,6 +1309,7 @@ > <th id="item_url" data-colname="item_url" class="url">URL</th> > <th id="item_copy" data-colname="item_copy" class="copynumber">Copy number</th> > <th id="item_status" data-colname="item_status" class="status">Status</th> >+ <th id="item_displays" data-colname="item_displays" class="displays">Displays</th> > <th id="item_notes" data-colname="item_notes" class="notes">Notes</th> > <th id="item_datedue" data-colname="item_datedue" class="date_due">Date due</th> > <th id="item_barcode" data-colname="item_barcode" class="barcode">Barcode</th> >@@ -1355,8 +1356,8 @@ > [% END %] > [% IF ( OpacLocationBranchToDisplay == 'holding' || OpacLocationBranchToDisplay == 'both' ) %] > [%# Show opac_info or branchurl from holding library %] >- [% SET holding_library_name = Branches.GetName( ITEM_RESULT.holdingbranch ) %] >- [% SET holding_library_url = Branches.GetURL( ITEM_RESULT.holdingbranch ) %] >+ [% SET holding_library_name = ITEM_RESULT.holding_branch.branchname %] >+ [% SET holding_library_url = Branches.GetURL( ITEM_RESULT.holding_branch.branchcode ) %] > <td class="location" property="seller" data-order="[% holding_library_name | html %]"> > <link property="itemOffered" href="#record" /> > <link property="businessFunction" href="http://purl.org/goodrelations/v1#LeaseOut" /> >@@ -1381,8 +1382,8 @@ > > [% IF ( OpacLocationBranchToDisplay == 'home' || OpacLocationBranchToDisplay == 'both' ) %] > [%# Show opac_info or branchurl from home library %] >- [% SET home_library_name = Branches.GetName( ITEM_RESULT.homebranch ) %] >- [% SET home_library_url = Branches.GetURL( ITEM_RESULT.homebranch ) %] >+ [% SET home_library_name = ITEM_RESULT.home_branch.branchname %] >+ [% SET home_library_url = Branches.GetURL( ITEM_RESULT.home_branch.branchcode ) %] > <td class="location" property="seller" data-order="[% home_library_name | html %]"> > <link property="itemOffered" href="#record" /> > <link property="businessFunction" href="http://purl.org/goodrelations/v1#LeaseOut" /> >@@ -1532,8 +1533,26 @@ > > <td class="status">[% INCLUDE 'item-status.inc' item = ITEM_RESULT.object include_schema_org = 1 %]</td> > >- [% IF ( itemdata_itemnotes ) %] >- <td class="notes" property="description">[% ITEM_RESULT.itemnotes | $raw %]</td> >+ [% IF ( itemdata_displays ) %] >+ <td class="displays"> >+ <ul> >+ [% FOREACH display IN ITEM_RESULT.displays %] >+ <li>[% display.display_name | html %]</li> >+ [% END %] >+ </ul> >+ </td> >+ [% ELSE %] >+ [% hidden_columns_force.$table_id.push('item_displays') %] >+ <td></td> >+ [% END %] >+ >+ [% IF ( itemdata_itemnotes || itemdata_displaynotes ) %] >+ <td class="notes" property="description"> >+ [% ITEM_RESULT.itemnotes | $raw %] >+ [% IF ( ITEM_RESULT.displaynotes ) %] >+ <p><span class="on_display public_note">[% ITEM_RESULT.displaynotes | $raw %]</span></p> >+ [% END %] >+ </td> > [% ELSE %] > [% hidden_columns_force.$table_id.push('item_notes') %] > <td></td> >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index edf609cb021..c9aacc45c90 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -727,11 +727,13 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) { > $can_holds_be_placed || $patron && IsAvailableForItemLevelRequest( $item, $patron, undef ); > > # get collection code description, too >- my $ccode = $item->ccode; >+ my $ccode = $item->effective_collection_code; > $item_info->{'ccode'} = $collections->{$ccode} >- if defined($ccode) >- && $collections >- && exists( $collections->{$ccode} ); >+ if defined($ccode) && $collections && exists( $collections->{$ccode} ); >+ >+ my $location = $item->effective_location; >+ $item_info->{'location_description'} = $shelflocations->{$location} >+ if defined($location) && $shelflocations && exists( $shelflocations->{$location} ); > > my $copynumber = $item->copynumber; > $item_info->{copynumber} = $copynumbers->{$copynumber} >@@ -739,11 +741,42 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) { > && defined($copynumber) > && exists( $copynumbers->{$copynumber} ) ); > >- if ( defined $item->location ) { >- $item_info->{'location_description'} = $shelflocations->{ $item->location }; >+ $item_info->{holding_branch} = $item->holding_branch; >+ $item_info->{home_branch} = $item->home_branch; >+ >+ if ( C4::Context->preference('UseDisplayModule') && $item->effective_homebranch ) { >+ my $effective_homebranch = $item->effective_homebranch; >+ my $effective_homebranch_id = $item->effective_homebranch->branchcode; >+ my $effective_homebranch_opac_info = $item->effective_homebranch->opac_info( { lang => $lang } ); >+ >+ $item_info->{home_library_info} = $effective_homebranch_opac_info >+ if ($effective_homebranch_opac_info); >+ >+ # If it starts with "DISPLAY:", use it as-is, otherwise look it up >+ if ( $effective_homebranch_id =~ /^DISPLAY:/ ) { >+ $item_info->{home_branch} = $effective_homebranch_id; >+ } else { >+ $item_info->{home_branch} = $effective_homebranch; >+ } >+ } >+ >+ if ( C4::Context->preference('UseDisplayModule') && $item->effective_holdingbranch ) { >+ my $effective_holdingbranch = $item->effective_holdingbranch; >+ my $effective_holdingbranch_id = $item->effective_holdingbranch->branchcode; >+ my $effective_holdingbranch_opac_info = $item->effective_homebranch->opac_info( { lang => $lang } ); >+ >+ $item_info->{holding_library_info} = $effective_holdingbranch_opac_info >+ if ($effective_holdingbranch_opac_info); >+ >+ # If it starts with "DISPLAY:", use it as-is, otherwise look it up >+ if ( $effective_holdingbranch_id =~ /^DISPLAY:/ ) { >+ $item_info->{holding_branch} = $effective_holdingbranch_id; >+ } else { >+ $item_info->{holding_branch} = $effective_holdingbranch; >+ } > } > >- my $itemtype = $item->itemtype; >+ my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); > $item_info->{'imageurl'} = getitemtypeimagelocation( > 'opac', > $itemtypes->{ $itemtype->itemtype }->{'imageurl'} >@@ -754,8 +787,31 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) { > $item_info->{checkout} = $item->checkout; > if ( $item_info->{checkout} && $item_info->{checkout} > 0 ) { $item_checkouts = 1; } > >+ if ( C4::Context->preference('UseDisplayModule') ) { >+ my @displays; >+ my @display_items = Koha::DisplayItems->search( >+ { itemnumber => $item->itemnumber }, >+ { >+ order_by => { '-desc' => 'date_added' }, >+ } >+ )->as_list; >+ >+ foreach my $display_item (@display_items) { >+ push @displays, $display_item->display; >+ } >+ >+ foreach my $display (@displays) { >+ $item_info->{displaynotes} .= $display->public_note >+ if ( $display->public_note ); >+ } >+ >+ $item_info->{display_items} = \@display_items if @display_items; >+ $item_info->{displays} = \@displays if @displays; >+ } >+ > foreach my $field ( >- qw(ccode materials enumchron copynumber itemnotes location_description uri barcode itemcallnumber)) >+ qw(ccode materials enumchron copynumber itemnotes location_description uri barcode itemcallnumber displaynotes displays display_items) >+ ) > { > $itemfields{$field} = 1 if $item_info->{$field}; > } >@@ -777,9 +833,6 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) { > $item_info->{course_reserves} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber ); > } > >- $item_info->{holding_branch} = $item->holding_branch; >- $item_info->{home_branch} = $item->home_branch; >- > my $itembranch = $item->$separatebranch; > if ( $currentbranch > and C4::Context->preference('OpacSeparateHoldings') ) >@@ -837,6 +890,9 @@ $template->param( > itemdata_location => $itemfields{location_description}, > itemdata_barcode => $itemfields{barcode}, > itemdata_itemcallnumber => $itemfields{itemcallnumber}, >+ itemdata_displaynotes => $itemfields{displaynotes}, >+ itemdata_displays => $itemfields{displays}, >+ itemdata_display_items => $itemfields{display_items}, > OpacStarRatings => C4::Context->preference("OpacStarRatings"), > ); > >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 892de210c2c..cea3f7bf81f 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -348,7 +348,13 @@ foreach my $biblioNumber (@biblionumbers) { > { prefetch => [ 'issue', 'homebranch', 'holdingbranch' ] } > )->filter_by_visible_in_opac( { patron => $patron } ); > >- $biblioData->{items} = [ $items->as_list ]; # FIXME Potentially a lot in memory here! >+ foreach my $item ( $items->as_list ) { >+ $item->{'ccode'} = $item->effective_collection_code; >+ $item->holdingbranch( $item->effective_holdingbranch->branchcode ); >+ $item->homebranch( $item->effective_homebranch->branchcode ); >+ >+ push @{ $biblioData->{items} }, $item; # FIXME Potentially a lot in memory here! >+ } > > # Compute the priority rank. > $biblioData->{object} = $biblio; >@@ -431,6 +437,34 @@ foreach my $biblioNum (@biblionumbers) { > my $item_info = $item->unblessed; > $item_info->{holding_branch} = $item->holding_branch; > $item_info->{home_branch} = $item->home_branch; >+ >+ $item_info->{'ccode'} = $item->effective_collection_code >+ if ( C4::Context->preference('UseDisplayModule') && $item->effective_collection_code ); >+ >+ if ( C4::Context->preference('UseDisplayModule') && $item->effective_homebranch ) { >+ my $effective_homebranch = $item->effective_homebranch; >+ my $effective_homebranch_id = $item->effective_homebranch->branchcode; >+ >+ # If it starts with "DISPLAY:", use it as-is, otherwise look it up >+ if ( $effective_homebranch_id =~ /^DISPLAY:/ ) { >+ $item_info->{holding_branch} = $effective_homebranch_id; >+ } else { >+ $item_info->{holding_branch} = $effective_homebranch; >+ } >+ } >+ >+ if ( C4::Context->preference('UseDisplayModule') && $item->effective_holdingbranch ) { >+ my $effective_holdingbranch = $item->effective_holdingbranch; >+ my $effective_holdingbranch_id = $item->effective_holdingbranch->branchcode; >+ >+ # If it starts with "DISPLAY:", use it as-is, otherwise look it up >+ if ( $effective_holdingbranch_id =~ /^DISPLAY:/ ) { >+ $item_info->{home_branch} = $effective_holdingbranch_id; >+ } else { >+ $item_info->{home_branch} = $effective_holdingbranch; >+ } >+ } >+ > if ($itemLevelTypes) { > my $itemtype = $item->itemtype; > $item_info->{'imageurl'} = getitemtypeimagelocation( >-- >2.53.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14962
:
190216
|
190217
|
190218
|
190219
|
190220
|
190221
|
190222
|
190223
|
190224
|
190225
|
190226
|
190227
|
190228
|
190229
|
190230
|
190231
|
190232
|
190571
|
190572
|
193719
|
193720
|
193721
|
193722
|
193723
|
193724
|
193725
|
193726
|
193727
|
193728
|
193729
|
193730
|
193731
|
193732
|
193733
|
193734
|
193735
|
193736
|
193737
|
193738
|
193739
|
193740
|
193741
|
193742
|
193743
|
193744
|
193745
|
193746
|
193747
|
193748
|
193749
|
193750
|
193751
|
193752
|
193753
|
193754
|
193755
|
194285
|
194286
|
194287
|
194288
|
194289
|
194290
|
194291
|
194292
|
194293
|
194294
|
194295
|
194296
|
194297
|
194298
|
194299
|
194300
|
194301
|
194302
|
194303
|
194304
|
194305
|
194306
|
194307
|
194308
|
194309
|
194310
|
194311
|
194312
|
194313
|
194314
|
194315
|
194316
|
194317
|
194318
|
194320
|
194321
|
194322