> Forums > Active Forums > Feedback and Requests > TopPosts Enhancement: "Latest post in thread"
Last Post 28 Sep 2005 12:19 PM by Joe Pruitt. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Joe Pruitt
Customers
Joe Pruitt
Post Count:24

--
28 Sep 2005 12:19 PM
    Currently the TopPosts module allows you to either view the latest "n" number of posts including all replies -OR- the latest "n" initial posts disregarding all the replies.

    I'd suggest adding something in the middle. Allowing listing only the latest post from each thread (either the original post or the latest reply). This will essentially give a "latest post in thread" view.

    I've added this to my site and it works well. I basically overrode the current ActiveForums_GetTopPostsTopics stored procedure with mine until this gets incorporated in the product.

    CREATE PROCEDURE dbo.ActiveForums_GetTopPostsTopics
    (
    @PortalID int,
    @Forums nvarchar(1000),
    @Rows int
    )
    AS
    exec ('SELECT Top ' + @Rows + ' FG.PortalID, F.ModuleID, FG.GroupName, F.Name,
    F.ForumID, F.AuthorizedRoles, F.CanView,F.CanRead, P.PostID, P.ParentPostID, P.Subject,
    P.Body, P.UserID, P.UserName, P.DateAdded, P.Approved,
    IsNull(U.FirstName, '''') as FirstName, IsNull(U.LastName,'''') as LastName,
    P.Deleted, TM.TabID, P.Replies
    FROM NTForums_Posts P INNER JOIN
    NTForums_Forums F ON P.ForumID = F.ForumID INNER JOIN
    NTForums_ForumGroups FG ON F.ForumGroupID = FG.ForumGroupID INNER JOIN
    TabModules TM ON FG.ModuleID = TM.ModuleID LEFT OUTER JOIN
    Users U ON P.UserID = U.UserID
    WHERE (FG.PortalID = ' + @PortalID + ')
    AND (P.Approved = 1)
    AND (P.Deleted = 0)
    AND (P.ForumID IN (' + @Forums +'))
    AND P.PostID in
    (
    select top ' + @Rows + ' "PostID" =
    case when LastPostID is Not Null then LastPostID else PostID end
    from NTForums_Posts
    where ParentPostID = 0
    order by PostID DESC
    )
    ORDER By P.DateAdded DESC')
    GO
    Basically it takes either the LatestPostID or the PostID from the first post record and uses that as the PostID for the select.  I had to add the case statement in there because the LastPostID field is NULL until a reply is added to the thread.

    I'm not an SQL expert so I don't know if there is a more optimal way to do this.  If anyone has one, let me know...

    Will, any chance on adding this as another feature to the Top Posts module in the near future?  If not, then I could take a stab at it and pass along the sources back to you.

    -Joe
    You are not authorized to post a reply.
    > Forums > Active Forums > Feedback and Requests > TopPosts Enhancement: "Latest post in thread"
    test
    Copyright 2012 by DotNetNuke Corporation / Terms of Use / Privacy