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 <mercury@coffee.geek.nz>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3af877e78a)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Baptiste 2025-02-06 17:27:28 +01:00 committed by Jacob O'Mara
parent b56ffb911d
commit 4e4458e254
No known key found for this signature in database
1 changed files with 4 additions and 1 deletions

View File

@ -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 );
}