Bug 39027 - News are ordered with oldest on top
Summary: News are ordered with oldest on top
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Baptiste Wojtkowski (bwoj)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-04 14:12 UTC by Marion Durand
Modified: 2025-05-12 07:29 UTC (History)
4 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 39027: Order news on opac-main.pl by publication date instead of ID (1.47 KB, patch)
2025-02-06 16:32 UTC, Baptiste Wojtkowski (bwoj)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marion Durand 2025-02-04 14:12:34 UTC
When a news is created, it is displayed last in the news list at the OPAC.

You can change that behaviors by using the field 'Number' to order them manually but then, you have to manually edit all news to add a new one first.
Comment 1 Owen Leonard 2025-02-05 19:23:57 UTC
It looks like the sort by "Number" is hard-coded, so we'd have to update the code to offer alternatives. I think it would be logical to add the option of sorting by date ascending or date descending.

I'm not sure how you'd handle sorting first by number and then by date.
Comment 2 Baptiste Wojtkowski (bwoj) 2025-02-06 16:32:27 UTC
Created attachment 177588 [details] [review]
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
Comment 3 Baptiste Wojtkowski (bwoj) 2025-02-06 16:35:21 UTC
@Owen, oh sry I did not see your comment before publishing

How would the sort be chosen ? By a syspref ?
Comment 4 Oliver Behnke 2025-05-09 08:07:08 UTC
Can we expand this issue to cover the staff interface as well? News can be displayed in both places and it suffers from that problem as well.

Honestly, sorting by publish date ascending doesn't make any sense to me, so one could even think about changing the default to descending :) If not, then a syspref would be much appreciated.

Cheers
Comment 5 David Nind 2025-05-11 22:16:09 UTC
Normally, for a news site, you would want to see the latest news item at the top (well, I would anyway).

But I also understand that this may not suit everyone, and how different libraries use the news feature.

How about a link/button to sort by latest or earliest? Not sure how to do this and make it look nice.

But then this would muck up the numbered option that you can set, which is also used for HTML customisations.

If sorting by "Appear in position" is not used, then it shouldn't be shown on the form.

I guess "we" will have to choose!

So maybe the logic would be:
1. If there is an "Appear in position" value, show in the order specified. 
2. If some "Appear in position" values, show in the specified order then by date published with the latest first.
3. If there is no "Appear in position" values, sort with the latest item first (published date).
4. Have a link to sort by latest/oldest.
5. Something else?
6. Give up and leave 

Current behavour for news:
1. If no "Appear in position", news is displayed by the creation date, with the earliest date first (?).
2. Use "Appear in position" to sort in your preferred order.
3. If "Appear in position" is only used on some items, sorts in descending order (2, 1, ...) with ones without after this in the date created order.

Behavour after the patch for both OPAC and staff interface:
1. Displayed by published date, with the oldest at the top and the latest at the bottom.

Changing status to in discussion.
Comment 6 Oliver Behnke 2025-05-12 07:29:16 UTC
I think I'd prefer a syspref to define the default order (publish data asc/desc). If there's an override via "Appear in position" then respect that.

What I don't like is a link/button to change the order interactively, *if* users have to click it every time - i.e. due to a lacking desired default.