From 78787057b9d9f67efd925a3d4b21dfc15f727fda Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 6 Feb 2025 17:27:28 +0100 Subject: [PATCH] Bug 39027: Order news on opac-main.pl by publication date instead of ID On the OPAC, news should rather be ordered by the publication date than by the creation date (~ id): a user want to see last published news first and not last created news, regardless of their publication date TEST PLAN: 1 - Create 3 news, have the 3 news published in an order different from their id (for example news 1 => 2020, news 2 => 2025, news 3 => 2023) 2 - Go on http://youropac/cgi-bin/koha/opac-main.pl -> news are ordered by ID APPLY PATCH 3 - Repeat 2 -> news are ordered by Date Signed-off-by: Mercury --- Koha/AdditionalContents.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm index 98a1b16..a30123d 100644 --- a/Koha/AdditionalContents.pm +++ b/Koha/AdditionalContents.pm @@ -105,7 +105,10 @@ sub search_for_display { $search_params->{-or} = [ { 'lang' => $lang }, '-and' => [ 'lang', 'default', \$subquery ] ] if !$search_params->{lang}; - my $attribs = { prefetch => 'additional_content', order_by => 'additional_content.number' }; + my $attribs = { + prefetch => 'additional_content', + order_by => { -desc => 'additional_content.published_on' } + }; return Koha::AdditionalContentsLocalizations->search( $search_params, $attribs ); } -- 2.39.5