Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

comment order


Reply

3 Posts   854 Views

Avatar
crf

26 March 2009 at 8:15am Community Member, 2 Posts

Is there a way to reverse the order of the comments without editing the core code so that the newest comments are at the bottom?

Avatar
Double-A-Ron

26 March 2009 at 9:54am Community Member, 604 Posts

Not that I'm aware, but it would be a nice simple feature for managing from the cms.

\sapphire\core\model\SiteTree.php
Line 288

public function Comments() {
      $spamfilter = isset($_GET['showspam']) ? '' : 'AND IsSpam=0';
      $unmoderatedfilter = Permission::check('ADMIN') ? '' : 'AND NeedsModeration = 0';
      $comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->ID) . "' $spamfilter $unmoderatedfilter", "Created DESC");
      
      return $comments ? $comments : new DataObjectSet();
   }

I think changing "Created DESC" to "Created ASC" will do what you want.

Cheers
Aaron

Avatar
crf

26 March 2009 at 10:13am Community Member, 2 Posts

I agree. I think it would be a nice simple feature for the cms.

That was the code I didn't want to edit, but looks like I don't have a choice. Oh well. Thanks for the response.

Chris