Bug 41402

Summary: Do not hide all items if there is a pref OpacMaxItemsToDisplay
Product: Koha Reporter: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Component: OPACAssignee: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the number of items shown for a record in the OPAC when OpacMaxItemsToDisplay is used. It should only show the number of items in the system preference. Instead, it was showing no items if the number was reached. Example: With a record that has four items and OpacMaxItemsToDisplay set to three, no items were shown and you had to click "View all the physical items". Now it works as expected, three items are shown and you click "View all the physical items" to see all four items.
Version(s) released in:
Circulation function:
Attachments: Bug 41402: Do not hide all items if there is a pref OpacMaxItemsToDisplay
Bug 41402: Do not hide all items if there is a pref OpacMaxItemsToDisplay
Bug 41402: Do not hide all items if there is a pref OpacMaxItemsToDisplay

Description Baptiste Wojtkowski (bwoj) 2025-12-08 15:32:04 UTC
If there are too much items to process according to OpacMaxItemsToDisplay, ALL items are hidden. It is a bit weird to display every single of the n-1 items, but none of the n items once OpacMaxItemsToDisplay is reached. I propose to change the behaviour of this syspref to only display the first OpacMaxItemsToDisplay items and have a link to see more.
Comment 1 Baptiste Wojtkowski (bwoj) 2025-12-08 15:41:11 UTC
Created attachment 190288 [details] [review]
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
Comment 2 Baptiste Wojtkowski (bwoj) 2025-12-08 15:48:24 UTC
Note : 
From a technical point of view, there is no real change concerning the load. All items were formerly fetched and none were processed.
Now, all items are still fetched and OpacMaxItemsToDisplay are processed, which is supposed to be low enough to guarantee correct response time.
Comment 3 David Nind 2025-12-08 22:26:21 UTC Comment hidden (obsolete)
Comment 4 David Nind 2025-12-08 22:32:36 UTC
Changed bug from an enhancement to normal (as it is a bug), also changed the assignee.
Comment 5 David Nind 2025-12-09 00:50:43 UTC
Created attachment 190321 [details] [review]
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 <david@davidnind.com>
Comment 6 David Nind 2025-12-09 00:51:03 UTC
My sign-off line was incorrect, so have updated.