Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Let me explain by example, suppose we have forum id 2000 and set default sort by desc with order by last_comment_timestamp
Sample forum topic:
nid, title, created, changed, last_reply, last_comment_timestamp
100, Topic A, 1 Jan 2012, 1 Jan 2012, 2 Jan 2012, 2 Jan 2012
101, Topic B, 2 Jan 2012, 2 Jan 2012, none, 2 Jan 2012
102, Topic C, 3 Jan 2012, 3 Jan 2012, none, 3 Jan 2012
Current order in forum/2000 (which is not as I wish):
nid, title, created, changed, last_reply, last_comment_timestamp
102, Topic C, 3 Jan 2012, 3 Jan 2012, none, 3 Jan 2012
101, Topic B, 2 Jan 2012, 2 Jan 2012, none, 2 Jan 2012
100, Topic A, 1 Jan 2012, 1 Jan 2012, 2 Jan 2012, 2 Jan 2012
Expect:
nid, title, created, changed, last_reply, last_comment_timestamp
100, Topic A, 1 Jan 2012, 1 Jan 2012, 2 Jan 2012, 2 Jan 2012
102, Topic C, 3 Jan 2012, 3 Jan 2012, none, 3 Jan 2012
101, Topic B, 2 Jan 2012, 2 Jan 2012, none, 2 Jan 2012
The field "last_comment_timestamp" should not be used if there's no comment on that topic,
so I've made my own patch as attached, the patch fix SQL to count and order only the node that has comments.
Comment | File | Size | Author |
---|---|---|---|
forum-topic-order-last-comment-timestamp.patch | 2.72 KB | noomz | |
Comments
Comment #1
noomz CreditAttribution: noomz commentedComment #3
larowlanSo this is about the treatment of NULL?