Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Change sort order of PageComments

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1203 Views
  • tmkp
    Avatar
    Community Member
    40 Posts

    Change sort order of PageComments Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Change sort order of PageComments Link to this post

    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.

  • tmkp
    Avatar
    Community Member
    40 Posts

    Re: Change sort order of PageComments Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Change sort order of PageComments Link to this post

    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.

    1203 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.