Closed carlosgarcia8 closed 7 years ago
Hi, by default I have the following order of comments - link
All oldest replies of comments at first
Thats how I would like it to be, but this is what Im getting - link
You need to create your own CommentModel and override getTree
method with the custom sorting
What MySQL version do you use?
I am using PostgreSQL 9.5.6, so I need to override the CommentModel, use the yii2mod\comments\models\CommentModel as the base and extends from it, then override the getTree to make my custom sorting, right?
yes, you right. After that, you need to override commentModelClass
in the CommetModule by the following code:
'modules' => [
'comment' => [
'class' => 'yii2mod\comments\Module',
'commentModelClass' => 'path to your custom CommentModel',
],
]
Okay, Thank you for your answers. By the way, the problem that your default sort is different than mine is because I use postgresql and you mysql? That makes no sense to me
I agree with you, but I don't know why comments in our projects have different sorting.
Well, I'm going to override it and work on it and if I find out why we have different sorting I'll let you know.
Ok, thanks!
I added order to getTree
. Can you update your package to dev-master
version and check it again?
Yea this way it works as it has to!
Cool, thanks!
I would like to see the replies of a comment with the oldest at first and the newer at the bottom, like youtube. Is it possible? By default it works the other way around.
Example: carlos -- Hii 2 days ago anonymous -- Bye 1 day ago masteroftea -- Haha 1 minute ago