Hi everybody,
i'm looking for a way to change the sort order of page comments from "newest first" to "oldest first". Seems like such a simple thing to do, but i couldn't find a solution.
What would be the correct/easiest way to do this, any pointers?
Thanks a bunch!
Andi
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
It appears sort order is hard coded in the query - On line 215 of PageCommentInterface
DataObject::get("PageComment", "\"ParentID\" = '" . Convert::raw2sql($this->page->ID) . "' $spamfilter $unmoderatedfilter", '"Created" DESC', "", $limit);
If you wanted to change it you would need to change the DESC to ASC. It would be better if that sort field was a static variable you could set like PageCommentInterface::sort_comments('Created ASC'); I guess. Might be a nice enhancement ticket.
Hey Willr,
thanks for looking into this.. I can't believe that nobody seems to have run into this issue before.
I agree, it would be great to have this option available without hacking the core.
Just so we can track the issue - I've made http://open.silverstripe.org/ticket/5130. Should be simple to implement so when I next have a spare 2 mins to add it and test it'll be sorted.