How to reverse the order of posts in the Forum - to last one on top

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
I would like to change the order of posts showing in the Forum (ie. the latest post on top and the oldest on the bottom of the last page)    ...i was just wondering why it did not bother anybody that you must always scroll down to the last page's bottom to see what were the last posts in the topic.

Is there an easy way to modify the source code ?  I suppose it should be as easy as adding a DESC to an 'Order By' parameter somewhere into a SQL query,  could someone give me a clue where to find it ?    ..or is it not that easy ?

I currently run v.1.9 but soon will move to v.2.1  (so a clue to any of these both versions' code would be appreciated)
12 years ago
I found it in vesion 1.9    I post it in case someone else is interested in changing the forum's order to descending.

In file ForumService.cs
        public PagedList<ForumPost> GetAllPosts(int forumTopicId,
            int userId, string keywords, int pageIndex, int pageSize)
        {
            return GetAllPosts(forumTopicId, userId, keywords, true,          // <----  set this to false
                pageIndex, pageSize);                                                       // the 4th parameter is the sort order
         }
        ....

Seems to work OK at first sight, though still need to test if there are no erroneous side-effects elsewhere (when posting, editing, etc)
Edit:  At least one side-effect found:  after posting a new post, the last page is displayed (with the oldest post in this reverse order case). so now Looking for the 'Post' function.
Solved:
        public int CalculateTopicPageIndex(int forumTopicId, int pageSize, int postId)
        {
            int pageIndex = 0;
            var forumPosts = GetAllPosts(forumTopicId, 0,
                string.Empty, true, 0, int.MaxValue); ...              //<---  change this also to false  for ascending order
                                           //this function is used to calculated which page to show after posting a new post


And also I disabled the delete topic function, when the 'first' post (ie. the last one in this case) is deleted:

        public void DeletePost(int forumPostId)
        {
            ....
            if (forumTopic != null)
            {
                ForumPost firstPost = forumTopic.FirstPost;
                if (firstPost != null && firstPost.ForumPostId == forumPostId)
                {
                    //deleteTopic = true;                                    //comment this out -  do not delete the topic
                }
            }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.