Print Page | Close Window

Latest Posts

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=30161
Printed Date: 29 March 2026 at 9:21am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Latest Posts
Posted By: Agni
Subject: Latest Posts
Date Posted: 16 February 2012 at 12:10pm
I've upgraded from an older version of WWG and am not keen on the way the 'Latest Posts' repeats the topic several times in the list, for each time it has been posted to.


The old version of WWG, that I was using did not do this.

Looking at the code (I'm using a MY SQL version) I think I need to add a 'DISTINCT' somewhere. can anyone help?

Many thanks.  Agni

'Get the last x posts from the database
strSQL = "" & _
"SELECT "
If strDatabaseType = "SQLServer" OR strDatabaseType = "Access" Then
strSQL = strSQL & " TOP " & intLatestPostsMaxNo & " "
End If
strSQL = strSQL & _
"" & strDbTable & "Forum.Forum_ID, " & strDbTable & "Forum.Forum_name, " & strDbTable & "Topic.Topic_ID, " & strDbTable & "Topic.Subject, " & strDbTable & "Thread.Thread_ID, " & strDbTable & "Thread.Message_date, " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username, " & strDbTable & "Thread.Message  " & _
"FROM " & strDbTable & "Forum, " & strDbTable & "Topic, " & strDbTable & "Author, " & strDbTable & "Thread " & _
"WHERE " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Topic.Forum_ID " & _
"AND " & strDbTable & "Topic.Topic_ID = " & strDbTable & "Thread.Topic_ID " & _
"AND " & strDbTable & "Author.Author_ID = " & strDbTable & "Thread.Author_ID "



Replies:
Posted By: Scotty32
Date Posted: 16 February 2012 at 1:02pm

If you don't want it to repeat the same topic there is always my http://www.s2h.co.uk/wwf/mods/latest-topics/" rel="nofollow - Latest Topics mod.



-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: Agni
Date Posted: 18 February 2012 at 6:11am
Thanks for that Scotty, however I would rather just tweak the SQl query to do it. I find it strange that no one else doesn't want the same. If you have a popular topic and get 5 fast posts, then the latest posts is filled with 5 identical topics. 


Posted By: WebWiz-Bruce
Date Posted: 20 February 2012 at 10:13am
The way the latest posts on the homepage works has already been updated for the next release so that it only shows the first latest post for a topic, so that it does not repeat the same topic multiple times.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: Agni
Date Posted: 20 February 2012 at 10:19am
Thanks Bruce. Any chance I could have the updated query so that I can fix my version now?




Posted By: WebWiz-Bruce
Date Posted: 20 February 2012 at 10:26am
The new SQL code in includes/latest_posts_inc.asp is below:-

'Get the last x posts from the database
strSQL = "" & _
"SELECT "
If strDatabaseType = "SQLServer" OR strDatabaseType = "Access" Then
strSQL = strSQL & " TOP " & intLatestPostsMaxNo & " "
End If
strSQL = strSQL & _
"" & strDbTable & "Forum.Forum_ID, " & strDbTable & "Forum.Forum_name, " & strDbTable & "Topic.Topic_ID, " & strDbTable & "Topic.Subject, " & strDbTable & "Thread.Thread_ID, " & strDbTable & "Thread.Message_date, " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username, " & strDbTable & "Thread.Message  " & _
"FROM " & strDbTable & "Forum, " & strDbTable & "Topic, " & strDbTable & "Author, " & strDbTable & "Thread " & _
"WHERE " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Topic.Forum_ID " & _
"AND " & strDbTable & "Topic.Last_Thread_ID = " & strDbTable & "Thread.Thread_ID " & _
"AND " & strDbTable & "Author.Author_ID = " & strDbTable & "Thread.Author_ID "
'Check permissions
strSQL = strSQL & _
"AND (" & strDbTable & "Topic.Forum_ID " & _
"IN (" & _
"SELECT " & strDbTable & "Permissions.Forum_ID " & _
"FROM " & strDbTable & "Permissions" & strDBNoLock & " " & _
"WHERE (" & strDbTable & "Permissions.Group_ID = " & intGroupID & " OR " & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & ") " & _
"AND " & strDbTable & "Permissions.View_Forum = " & strDBTrue & _
")" & _
")"

'Don't include password protected forums
strSQL = strSQL & "AND (" & strDbTable & "Forum.Password = '' OR " & strDbTable & "Forum.Password Is Null) "

strSQL = strSQL & "AND (" & strDbTable & "Topic.Hide = " & strDBFalse & " AND " & strDbTable & "Thread.Hide = " & strDBFalse & ") " & _
"ORDER BY " & strDbTable & "Thread.Thread_ID DESC"

'mySQL limit operator
If strDatabaseType = "mySQL" Then
strSQL = strSQL & " LIMIT " & intLatestPostsMaxNo
End If
strSQL = strSQL & ";"


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: Agni
Date Posted: 20 February 2012 at 10:38am
Wow - brilliant. You star. Thanks mate. It works perfectly!

N


Posted By: doug-hoff
Date Posted: 20 February 2012 at 6:35pm
Spot on - much better Thumbs Up


Posted By: aussiem8
Date Posted: 23 March 2012 at 11:34pm
Yep, good for me too.

Is there a way this can also be applied to the RSS feed viewed with extras/recent_forum_posts.asp ?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net