Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Latest Posts
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Latest Posts

 Post Reply Post Reply Page  12>
Author
Agni View Drop Down
Newbie
Newbie


Joined: 02 July 2004
Location: Greece
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Agni Quote  Post ReplyReply Direct Link To This Post Topic: Latest Posts
    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 "
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 16 February 2012 at 1:02pm

If you don't want it to repeat the same topic there is always my Latest Topics mod.

S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
Agni View Drop Down
Newbie
Newbie


Joined: 02 July 2004
Location: Greece
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Agni Quote  Post ReplyReply Direct Link To This Post 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. 
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Agni View Drop Down
Newbie
Newbie


Joined: 02 July 2004
Location: Greece
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Agni Quote  Post ReplyReply Direct Link To This Post 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?


Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (1) Thanks(1)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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 & ";"
Back to Top
Agni View Drop Down
Newbie
Newbie


Joined: 02 July 2004
Location: Greece
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Agni Quote  Post ReplyReply Direct Link To This Post Posted: 20 February 2012 at 10:38am
Wow - brilliant. You star. Thanks mate. It works perfectly!

N
Back to Top
doug-hoff View Drop Down
Newbie
Newbie
Avatar

Joined: 03 November 2011
Location: United Kingdom
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote doug-hoff Quote  Post ReplyReply Direct Link To This Post Posted: 20 February 2012 at 6:35pm
Spot on - much better Thumbs Up
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.