Changing the order of blog comments on a blog post

geoff l asked on June 18, 2015 07:59

Hi,

I would like to know how I would go about changing the order of comments on a blog post. I notice by default they are ordered in descending order by date with the latest dated comment appearing at the top. I have noticed that in CMSModules/Blogs/Controls there is a file called Blogs_Comments which has an orderby for 'commentdate' though changing this does not appear to affect anything. Please Help if you can! Thanks!

Geoff

Correct Answer

geoff l answered on July 1, 2015 01:39

I found out that the data source is initialized in the file BlogCommentView.ascx.cs and has to be sorted here

0 votesVote for this answer Unmark Correct answer

Recent Answers


Nick Dubé answered on May 11, 2016 06:23

Hi Geoff,

Are you able to advise what edits are required in the BlogCommentView.ascx.cs to display comments in ascending order.

Thanks Nick

0 votesVote for this answer Mark as a Correct answer

geoff l answered on May 11, 2016 06:48

@Nick, this isn't quite what I required in my case but for yours I would imagine you would first sort the DataView object and then apply the Datasource e.g. put the following in place of rptComments.DataSource:

DataSet comments = BlogCommentInfoProvider.GetPostComments(PostNode.DocumentID, !isUserAuthorized, isUserAuthorized, DisplayTrackbacks); //Data to be sorted.
DataSet result = null; //Declare a dataSet to be filled.

// Sort data
comments.Tables[0].DefaultView.Sort = "CommentDate ASC";
// Store in new Dataset
result.Tables.Add(comments.Tables[0].DefaultView.ToTable());
rptComments.DataSource = result;
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.