/** * Sort the comments by popularity if necessary * @param CommentModel $CommentModel */ public function CommentModel_AfterConstruct_Handler($CommentModel) { // if (!C('Plugins.Voting.Enabled')) // return; $Sort = self::CommentSort(); switch (strtolower($Sort)) { case 'date': $CommentModel->OrderBy('c.DateInserted'); break; case 'popular': default: $CommentModel->OrderBy(array('coalesce(c.Score, 0) desc', 'c.CommentID')); break; } }