Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Change RSS topic feed to show unique topics only
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Change RSS topic feed to show unique topics only

 Post Reply Post Reply
Author
dan74 View Drop Down
Newbie
Newbie


Joined: 20 August 2007
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote dan74 Quote  Post ReplyReply Direct Link To This Post Topic: Change RSS topic feed to show unique topics only
    Posted: 17 March 2008 at 4:36pm
Hi,

We just made the following change to our forums (using version 9.06). By default, RSS_topic_feed.asp shows the most recent posts (or threads), but if you had one very popular topic, you see multiple items on this subject. We wanted to show the 10 distinct most recent updated topics.

In RSS_topic_feed.asp, where the SQL query between lines 129 and 158 is put together  you want to change the query so that instead of referencing tblthread.thread_id you use tbltopic.last_thread_id instead:

Around line 139:
"AND " & strDbTable & "Topic.Topic_ID = " & strDbTable & "Thread.Topic_ID " &_
And line 156:
"ORDER BY " & strDbTable & "Thread.Thread_ID DESC"
You can't simply insert DISTINCT into the query because in the original code the message field is a TEXT object, and the message_date and thread_ID would always be distinct anyway. Below is the revised query:
SELECT TOP 100 tblForum.Forum_name, tblTopic.Topic_ID, tblTopic.Subject, tbltopic.last_thread_id,
tblthread.message_date, tblthread.message, tblAuthor.Author_ID, tblAuthor.Username
FROM tblForum, tblTopic, tblthread, tblAuthor
WHERE tblForum.Forum_ID = tblTopic.Forum_ID AND
    tbltopic.last_thread_id = tblthread.thread_id AND
    tblauthor.Author_id = tblthread.author_id AND
    --permissions stuff edited out for clarity
ORDER BY tblTopic.last_thread_ID DESC;

Hope this helps anyone else.

Dan
Back to Top
Jeppe View Drop Down
Newbie
Newbie


Joined: 10 June 2008
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jeppe Quote  Post ReplyReply Direct Link To This Post Posted: 13 September 2008 at 8:26pm
Hi Dan,
 
It works perfectly. Thank you very much. Web Wiz really ought to include it as a standard in the forum package since we all seem to be asking for this feature.
 
I did have a few problems finding out exactly where to change the code, so now that it is working as intended I am posting the entire altered code here so that getting it to work is just a matter of copying it:
 
<% @ Language=VBScript %>
<% Option Explicit %>
<!-- #include file="includes/global_variables_inc.asp" -->
<!-- #include file="includes/setup_options_inc.asp" -->
<!-- #include file="includes/version_inc.asp" -->
<!-- #include file="database/database_connection.asp" -->
<!-- #include file="functions/functions_common.asp" -->
<!-- #include file="functions/functions_filters.asp" -->
<!-- #include file="functions/functions_format_post.asp" -->
<!-- #include file="language_files/language_file_inc.asp" -->
<!-- #include file="language_files/RTE_language_file_inc.asp" -->
<%
'****************************************************************************************
'** Copyright Notice   
'**
'**  Web Wiz Forums(TM)
'** 
http://www.webwizforums.com
'**                           
'**  Copyright (C)2001-2008 Web Wiz(TM). All Rights Reserved.
'** 
'**  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS UNDER LICENSE FROM 'WEB WIZ'.
'** 
'**  IF YOU DO NOT AGREE TO THE LICENSE AGREEMENT THEN 'WEB WIZ' IS UNWILLING TO LICENSE
'**  THE SOFTWARE TO YOU, AND YOU SHOULD DESTROY ALL COPIES YOU HOLD OF 'WEB WIZ' SOFTWARE
'**  AND DERIVATIVE WORKS IMMEDIATELY.
'** 
'**  If you have not received a copy of the license with this work then a copy of the latest
'**  license contract can be found at:-
'**
'** 
http://www.webwiz.net/license
'**
'**  For more information about this software and for licensing information please contact
'**  'Web Wiz' at the address and website below:-
'**
'**  Web Wiz, Unit 10E, Dawkins Road Industrial Estate, Poole, Dorset, BH15 4JD, England
'** 
http://www.webwiz.net
'**
'**  Removal or modification of this copyright notice will violate the license contract.
'**
'****************************************************************************************
 
'*************************** SOFTWARE AND CODE MODIFICATIONS ****************************
'**
'** MODIFICATION OF THE FREE EDITIONS OF THIS SOFTWARE IS A VIOLATION OF THE LICENSE 
'** AGREEMENT AND IS STRICTLY PROHIBITED
'**
'** If you wish to modify any part of this software a license must be purchased
'**
'****************************************************************************************
 
 
'Set the response buffer to true as we maybe redirecting
Response.Buffer = True
'Open database connection
Call openDatabase(strCon)
'Load in configuration data
Call getForumConfigurationData()
'If RSS is not enabled send the user away
If blnRSS = False Then
 'Clear server objects
 Call closeDatabase()
 'Redirect
 Response.Redirect("default.asp")
End If
'Include the date time format hear, incase a database hit is required if the date and time data is not in the web servers memory
%><!-- #include file="functions/functions_date_time_format.asp" --><%

'Declare variables
Dim sarryRssTopics 'Holds the RSS Feed recordset
Dim intCurrentRecord 'Holds the current record in the array
Dim strForumName 'Holds the forum name
Dim lngTopicID  'Holds the topic ID
Dim strSubject  'Holds the subject
Dim lngMessageID 'Holds the message ID
Dim dtmMessageDate 'Holds the message date
Dim lngAuthorID  'Holds the author ID
Dim strUsername  'Holds sthe authros user name
Dim strMessage  'Holds the post
Dim strRssChannelTitle 'Holds the channel name
Dim strTimeZone  'Holds the time zone for the feed
Dim dtmLastEntryDate 'Holds the date of the last message
Dim intRSSLoopCounter 'Loop counter

'This is the number of posts to include in the feed
Const intMaxResults = 10
'This is the Time to Live value so that RSS News Readers know how often to update their feed,
'if this is set to low you may consume to much bandwidth, to high and the RSS News Reader may not be updated fast enough
Const intTimeToLive = 30
'Set this to the time zone you require
strTimeZone = "+0000" 'See
http://www.sendmail.org/rfc/0822.html#5 for list of time zones
'Initliase variables
intForumID = 0
strRssChannelTitle = strMainForumName

'Set the content type for feed
Response.ContentType = "application/xml"
 

'Read in the forum ID
If isNumeric(Request.QueryString("FID")) Then intForumID = CInt(Request.QueryString("FID"))
 
'Get the last x posts from the database
strSQL = "" & _
"SELECT "
If strDatabaseType = "SQLServer" OR strDatabaseType = "Access" Then
 strSQL = strSQL & " TOP " & intMaxResults & " "
End If
strSQL = strSQL & _
"" & strDbTable & "Forum.Forum_name, " & strDbTable & "Topic.Topic_ID, " & strDbTable & "Topic.Subject, " & strDbTable & "Topic.Last_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 "
'If looking at a forum only, only get posts from tha forum
If intForumID <> 0 Then strSQL = strSQL & "AND " & strDbTable & "Topic.Forum_ID = " & intForumID & " "
Back to Top
 Post Reply Post Reply

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.