commit 454a6914b1297a2d09e4e3b6bc39f2bb4666285e (HEAD -> BZ41402-reb) Author: Baptiste Wojtkowski Date: Mon Dec 8 15:32:35 2025 +0000 Bug 41402: Do not hide all items if there is a pref OpacMaxItemsToDisplay Test plan: 1. Set OpacMaxItemsToDisplay to 3. 2. Add multiple items on a record. 3. Visit http://koha-ktd:8080/cgi-bin/koha/opac-detail.pl?biblionumber=YOUR_BIBLIONUMBER, notice every items are hidden. 4. Apply patch 5. Visit the same page, notice that the 3 first items are displayed Signed-off-by: David Nind 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..4e69a73fdf8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -595,8 +595,12 @@ [% WRAPPER tab_panel tabname="holdings" %] [% IF too_many_items %] -

This record has many physical items ([% items_count | html %]). View all the physical items.

- [% ELSIF ( itemloop.size ) %] +

This record has many physical items ([% items_count | html %]), some of them are hidden. + View all the physical items.

+ [% END %] + [% IF ( itemloop.size ) %] [% INCLUDE items_table items=itemloop tab="holdings" table_id="holdingst" %] [% IF specific_item %]

Show all items

diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index edf609cb021..3bf5ba344e6 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -698,14 +698,18 @@ my $can_holds_be_placed = $patron ? 0 : $holdable_items; my ( $itemloop_has_images, $otheritemloop_has_images ); my $item_level_holds; my $item_checkouts; -if ( not $viewallitems and $items->count > $max_items_to_display ) { +my $library_info; +my $nb_items_processed = 0; +while ( my $item = $items->next ) { + if ( not $viewallitems and $nb_items_processed >= $max_items_to_display ) { $template->param( too_many_items => 1, items_count => $items->count, ); -} else { - my $library_info; - while ( my $item = $items->next ) { + last; + } + $nb_items_processed = $nb_items_processed + 1; + my $item_info = $item->unblessed; $item_info->{holds_count} = $item_reserves{ $item->itemnumber }; if ( $item_info->{holds_count} && $item_info->{holds_count} > 0 ) { $item_level_holds = 1; } @@ -723,8 +727,7 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) { # We only need to check if we haven't determined holds can be placed # and if we don't have patron, we have already decided - $can_holds_be_placed = - $can_holds_be_placed || $patron && IsAvailableForItemLevelRequest( $item, $patron, undef ); + $can_holds_be_placed = $can_holds_be_placed || $patron && IsAvailableForItemLevelRequest( $item, $patron, undef ); # get collection code description, too my $ccode = $item->ccode; @@ -754,8 +757,8 @@ 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; } - foreach my $field ( - qw(ccode materials enumchron copynumber itemnotes location_description uri barcode itemcallnumber)) + foreach + my $field (qw(ccode materials enumchron copynumber itemnotes location_description uri barcode itemcallnumber)) { $itemfields{$field} = 1 if $item_info->{$field}; } @@ -796,7 +799,6 @@ if ( not $viewallitems and $items->count > $max_items_to_display ) { $itemloop_has_images++ if $item->cover_images->count; } } -} $template->param( item_checkouts => $item_checkouts,