Author |
Topic |
|
Machina
New Member
Switzerland
74 Posts |
Posted - 17 May 2004 : 11:20:39
|
Hi all, getting upset with this beautiful feature I rewrote some part of the code of inc_simple_slash.asp
I use the Site Integration MOD. So I just included this <!--#INCLUDE FILE="inc_simple_slash.asp" --> in my inc_site_left.asp and this is perfect.
I rewrote the code for 3 reasons :
1/ I wanted the LAST POSTS, that could be either topic or reply.
2/I had some SQL server problems. The recordsets were messy so I changed the method.
3/ SQL requests were messy :-) (Especially the mix of TOP and ORDER BY)
maybe some mistakes (I think the link to the more in reply, but I'm tired now )
<% '--------------------------------------------------- ' Originally from Gremlins Simple Slash MOD ' Hugely modified by Gael Jaboulay ' displays the last POSTS (means either topic or reply comparing the 2 tables) ' BEWARE : This version DOES NOT manage private Forums! '---------------------------------------------------
Const intTopicCount = 4 Const CharsToDisplay = 100 Const SLASHForumID = "ANY"
Dim objConn, rsTopics, rsReplies Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open strConnString
'------------ ' Get Topics '------------ SLASHstrSql = "SELECT TOP " & intTopicCount & " * FROM " SLASHstrSql = SLASHstrSql & strTablePrefix & "TOPICS ORDER BY T_DATE DESC"
Set cmdTemp = Server.CreateObject("ADODB.Command") Set rsTopics = Server.CreateObject("ADODB.Recordset") cmdTemp.CommandText = SLASHstrSql Set cmdTemp.ActiveConnection = objConn rsTopics.Open cmdTemp, , 3, 2
'------------ ' Get Replies '------------ SLASHstrSql = "SELECT TOP " & intTopicCount & " * FROM " SLASHstrSql = SLASHstrSql & strTablePrefix & "REPLY ORDER BY R_DATE DESC"
Set rsReplies = Server.CreateObject("ADODB.Recordset") cmdTemp.CommandText = SLASHstrSql Set cmdTemp.ActiveConnection = objConn rsReplies.Open cmdTemp, , 3, 2
'Create the HTML Table
Response.Write " <table border=""0"" cellspacing=""1"" cellpadding=""0"" bgcolor=""" & strTableBorderColor & """ width=""100%""><tr><td>" & vbNewline Response.Write " <table border=""0"" width=""100%"" cellspacing=""0"" cellpadding=""2"" align=""center"" bgcolor=""" & strForumCellColor & """>" & vbNewline Response.Write " <tr><td align=""center"" bgcolor=""" & strHeadCellColor & """><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b>Last posts</b></font></TD></tr>" & vbNewline
'Display Either a Topic or a Reply. The most recent is chosen
Dim LogicalSum
z=0
do while z < intTopicCount LogicalSum = "" if not rsTopics.eof then LogicalSum = "1" else LogicalSum = "0" end if if not rsReplies.eof then LogicalSum = LogicalSum & "1" else LogicalSum = LogicalSum & "0" end if ' I left some debug code ' Response.Write "<tr><td bgcolor=""" & strAltForumCellColor & """ align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """> <B>" & LogicalSum &"</B></font></td></tr>" ' Response.Write "<tr><td bgcolor=""" & strAltForumCellColor & """ align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """> <B>" & strToDate(rsTopics("T_DATE")) & " VS "& strToDate(rsReplies("R_DATE")) &"</B></font></td></tr>" Select Case LogicalSum Case "00" ' no more data, do nothing Case "01" ' DISPLAY REPLY, TOPIC recordset is EOF ' Get Subject of post SlashstrSql2 = "SELECT T_SUBJECT FROM " & strTablePrefix & "TOPICS WHERE TOPIC_ID = " & rsReplies("TOPIC_ID") Set rsSubject = objConn.Execute(SlashstrSql2) Response.Write "<tr><td bgcolor=""" & strAltForumCellColor & """ align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """> Reply to <B>" & ChkString(rsSubject("T_SUBJECT"),"title") & "</B></font></td></tr>" ' Count Replies SlashstrSql= "SELECT COUNT(TOPIC_ID) As Counting FROM " & strTablePrefix & "REPLY WHERE TOPIC_ID = " & rsReplies("TOPIC_ID") Set rsCount= objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" & strForumFontColor & """> " & Left(RemoveHTML(FormatStr(rsReplies("R_MESSAGE"))),CharsToDisplay) & "... <a href='topic.asp?TOPIC_ID=" & rsReplies("TOPIC_ID") & "&REPLY_ID=" & rsReplies("REPLY_ID") & "'>More >></a> Replies(" & rsCount("Counting") & ")</font></td></tr>" ' Get Name of Author SlashstrSql = "SELECT M_NAME FROM " & strTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsReplies("R_AUTHOR") Set rsAuthor = objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ > <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>From <b>" & rsAuthor("M_NAME") & " </b> on "& strToDate(rsReplies("R_DATE")) & "</font></td></tr>" Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ height=""5""></td></tr>" rsReplies.movenext Case "10" ' DISPLAY TOPIC, REPLY recordset is EOF Response.Write "<tr><td bgcolor=""" & strAltForumCellColor & """ align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """> New Topic: <B>" & ChkString(rsTopics("T_SUBJECT"),"title") & "</B></font></td></tr>" ' Count Replies SlashstrSql= "SELECT COUNT(TOPIC_ID) As Counting FROM " & strTablePrefix & "REPLY WHERE TOPIC_ID = " & rsTopics("TOPIC_ID") Set rsCount = objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" & strForumFontColor & """> " & Left(RemoveHTML(FormatStr(rsTopics("T_MESSAGE"))),CharsToDisplay) & "... <a href='topic.asp?TOPIC_ID=" & rsTopics("TOPIC_ID") & "'>More >></a> Replies(" & rsCount("Counting") & ")</font></td></tr>" ' Get Name of Author SlashstrSql = "SELECT * FROM " & strTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsTopics("T_AUTHOR") Set rsAuthor = objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ > <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>From <b>" & rsAuthor("M_NAME") & " </b> on " & strToDate(rsTopics("T_DATE")) & "</font></td></tr>" Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ height=""5""></td></tr>" rsTopics.movenext
Case "11" ' Choose the more recent, display it and move to next record from the more recent recordset if strToDate(rsTopics("T_DATE")) > strToDate(rsReplies("R_DATE")) then ' Current Topic Record more recent than current Reply Record. DISPLAY TOPIC Response.Write "<tr><td bgcolor=""" & strAltForumCellColor & """ align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """> New Topic: <B>" & ChkString(rsTopics("T_SUBJECT"),"title") & "</B></font></td></tr>" ' Count Replies SlashstrSql= "SELECT COUNT(TOPIC_ID) As Counting FROM " & strTablePrefix & "REPLY WHERE TOPIC_ID = " & rsTopics("TOPIC_ID") Set rsCount = objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" & strForumFontColor & """> " & Left(RemoveHTML(FormatStr(rsTopics("T_MESSAGE"))),CharsToDisplay) & "... <a href='topic.asp?TOPIC_ID=" & rsTopics("TOPIC_ID") & "'>More >></a> Replies(" & rsCount("Counting") & ")</font></td></tr>" ' Get Name of Author SlashstrSql = "SELECT * FROM " & strTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsTopics("T_AUTHOR") Set rsAuthor = objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ > <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>From <b>" & rsAuthor("M_NAME") & " </b> on " & strToDate(rsTopics("T_DATE")) & "</font></td></tr>" Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ height=""5""></td></tr>" rsTopics.movenext else 'Current Reply Record more recent than current Topic Record. DISPLAY REPLY ' Get Subject of post SlashstrSql2 = "SELECT T_SUBJECT FROM " & strTablePrefix & "TOPICS WHERE TOPIC_ID = " & rsReplies("TOPIC_ID") Set rsSubject = objConn.Execute(SlashstrSql2) Response.Write "<tr><td bgcolor=""" & strAltForumCellColor & """ align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """> Reply to <B>" & ChkString(rsSubject("T_SUBJECT"),"title") & "</B></font></td></tr>" ' Count Replies SlashstrSql= "SELECT COUNT(TOPIC_ID) As Counting FROM " & strTablePrefix & "REPLY WHERE TOPIC_ID = " & rsReplies("TOPIC_ID") Set rsCount= objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" & strForumFontColor & """> " & Left(RemoveHTML(FormatStr(rsReplies("R_MESSAGE"))),CharsToDisplay) & "... <a href='topic.asp?TOPIC_ID=" & rsReplies("TOPIC_ID") & "&REPLY_ID=" & rsReplies("REPLY_ID") & "'>More >></a> Replies(" & rsCount("Counting") & ")</font></td></tr>" ' Get Name of Author SlashstrSql = "SELECT M_NAME FROM " & strTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsReplies("R_AUTHOR") Set rsAuthor = objConn.Execute(SlashstrSql) Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ > <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>From <b>" & rsAuthor("M_NAME") & " </b> on "& strToDate(rsReplies("R_DATE")) & "</font></td></tr>" Response.Write "<tr><td bgcolor=""" & strForumCellColor & """ height=""5""></td></tr>" rsReplies.movenext end if End select z=z+1 loop
response.write "</table></td></tr></table>" & vbNewLine rsTopics2.Close() Set rsTopics2 = Nothing rsTopics.Close() Set rsTopics = Nothing rsReplies.Close() Set rsReplies = Nothing rsCount.Close() Set rsCount = Nothing rsAuthor.Close() Set rsAuthor = Nothing
objConn.Close() Set objConn = Nothing
Function RemoveHTML( strText ) Dim TAGLIST TAGLIST=";A;B;IMG;CENTER;FONT;PRE;BLOCKQUOTE;" Dim nPos1 Dim nPos2 Dim nPos3 Dim strResult Dim strTagName Dim bRemove Dim bSearchForBlock nPos1 = InStr(strText, "<") Do While nPos1 > 0 nPos2 = InStr(nPos1 + 1, strText, ">") If nPos2 > 0 Then strTagName = Mid(strText, nPos1 + 1, nPos2 - nPos1 - 1) strTagName = Replace(Replace(strTagName, vbCr, " "), vbLf, " ") nPos3 = InStr(strTagName, " ") If nPos3 > 0 Then strTagName = Left(strTagName, nPos3 - 1) End If If Left(strTagName, 1) = "/" Then strTagName = Mid(strTagName, 2) bSearchForBlock = False Else bSearchForBlock = True End If If InStr(1, TAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then bRemove = True If bSearchForBlock Then If InStr(1, BLOCKTAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then nPos2 = Len(strText) nPos3 = InStr(nPos1 + 1, strText, "</" & strTagName, vbTextCompare) If nPos3 > 0 Then nPos3 = InStr(nPos3 + 1, strText, ">") End If If nPos3 > 0 Then nPos2 = nPos3 End If End If End If Else bRemove = False End If If bRemove Then strResult = strResult & Left(strText, nPos1 - 1) strText = Mid(strText, nPos2 + 1) Else strResult = strResult & Left(strText, nPos1) strText = Mid(strText, nPos1 + 1) End If Else strResult = strResult & strText strText = "" End If nPos1 = InStr(strText, "<") Loop strResult = strResult & strText RemoveHTML = strResult End Function %>
|
Machina ------- http://www.jaboulay.fr -------- Snitz based site: http://www.itu.int/YLinICTs MODS Used : TMPJ's Header Cell Image, Site Integration, Front Page News, News Events Calendar, Nikkol's Usergroups, Simple Slash, Avatar, File Sharing, Links |
Edited by - Machina on 06 December 2004 03:57:03 |
|
stuF
Average Member
United Kingdom
561 Posts |
Posted - 17 May 2004 : 14:58:25
|
i remember somthing similar to this a whie ago, just what i was looking for, a few questions:
am i able to specify (and limit to) a single forum where posts can be retireved from? can i display topics and not replies? can i display topics from hidden forums? (sorry, just read it properly :P) can i use this code on 4/5 instances, each time pulling topics from different forums?
If so id like to use it as a primitive content management system, where users submit thier news/reviews/etc to the releant forum and it is displayed on the corresponding page on the website. |
http://36-degrees.co.uk |
Edited by - stuF on 17 May 2004 14:59:42 |
|
|
Machina
New Member
Switzerland
74 Posts |
Posted - 18 May 2004 : 02:59:09
|
quote: Originally posted by stuF
i remember somthing similar to this a whie ago, just what i was looking for, a few questions:
am i able to specify (and limit to) a single forum where posts can be retireved from? can i display topics and not replies? can i display topics from hidden forums? (sorry, just read it properly :P) can i use this code on 4/5 instances, each time pulling topics from different forums?
If so id like to use it as a primitive content management system, where users submit thier news/reviews/etc to the releant forum and it is displayed on the corresponding page on the website.
Good questions :-) 1/ Getting from a specific forum? I deleted the code about it! This is easy to do : Replace the 2 SQL statements by : '------------ ' Get Topics '------------ SLASHstrSql = "SELECT TOP " & intTopicCount & " * FROM " SLASHstrSql = SLASHstrSql & strTablePrefix & "TOPICS " IF SLASHForumID <> "ANY" THEN SLASHstrSql = SLASHstrSql & " WHERE FORUM_ID = " & SLASHForumID end if SLASHstrSql = SLASHstrSql & " ORDER BY T_DATE DESC"
*****************************************************************
'------------ ' Get Replies '------------ SLASHstrSql = "SELECT TOP " & intTopicCount & " * FROM " SLASHstrSql = SLASHstrSql & strTablePrefix & "REPLY " IF SLASHForumID <> "ANY" THEN SLASHstrSql = SLASHstrSql & " WHERE FORUM_ID = " & SLASHForumID end if SLASHstrSql = SLASHstrSql & " ORDER BY R_DATE DESC"
2/ If you want only last topics, just forget my code and use the original Simple Slash MOD.
3/ This displays ALL topics, replies, even hidden ones
4/didn't try several instances...
|
Machina ------- http://www.jaboulay.fr -------- Snitz based site: http://www.itu.int/YLinICTs MODS Used : TMPJ's Header Cell Image, Site Integration, Front Page News, News Events Calendar, Nikkol's Usergroups, Simple Slash, Avatar, File Sharing, Links |
Edited by - Machina on 18 May 2004 03:00:14 |
|
|
nlbaviu1
Starting Member
5 Posts |
Posted - 14 June 2004 : 09:38:21
|
Machina, as an ASP newby, how do I incorporate this into my default.asp ? |
|
|
Machina
New Member
Switzerland
74 Posts |
Posted - 30 June 2004 : 10:14:49
|
quote: Originally posted by nlbaviu1
Machina, as an ASP newby, how do I incorporate this into my default.asp ?
First get the Simple Slash MOD at http://www.snitzbitz.com/mods/default.asp, then apply my changes |
Machina ------- http://www.jaboulay.fr -------- Snitz based site: http://www.itu.int/YLinICTs MODS Used : TMPJ's Header Cell Image, Site Integration, Front Page News, News Events Calendar, Nikkol's Usergroups, Simple Slash, Avatar, File Sharing, Links |
|
|
blues
Starting Member
26 Posts |
Posted - 23 November 2004 : 07:17:55
|
hi machina i have this error
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/forum2/inc_simple_slash.asp, line 27
this line is
rsTopics.Open cmdTemp, , 3, 2
|
|
|
Machina
New Member
Switzerland
74 Posts |
Posted - 24 November 2004 : 03:22:20
|
quote: Originally posted by blues
hi machina i have this error
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/forum2/inc_simple_slash.asp, line 27
this line is
rsTopics.Open cmdTemp, , 3, 2
You are right, working on this I made the mistake to replace the generic Snitz code to specific SQL Server code concerning the creation of the recordset.
Try to change the creation of the recordsets as follow : replace what is in red by what is in blue:
Set cmdTemp = Server.CreateObject("ADODB.Command") Set rsTopics = Server.CreateObject("ADODB.Recordset") cmdTemp.CommandText = SLASHstrSql Set cmdTemp.ActiveConnection = objConn rsTopics.Open cmdTemp, , 3, 2
Set rsTopics = objConn.Execute(strSQL)
Set rsReplies = Server.CreateObject("ADODB.Recordset") cmdTemp.CommandText = SLASHstrSql Set cmdTemp.ActiveConnection = objConn rsReplies.Open cmdTemp, , 3, 2
Set rsReplies = objConn.Execute(strSQL) |
Machina ------- http://www.jaboulay.fr -------- Snitz based site: http://www.itu.int/YLinICTs MODS Used : TMPJ's Header Cell Image, Site Integration, Front Page News, News Events Calendar, Nikkol's Usergroups, Simple Slash, Avatar, File Sharing, Links |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 November 2004 : 18:44:25
|
This won't work on MySQL at all now. When releasing MOD's it's really a good idea to make sure they work with all the database types that Snitz supports. |
Kiwihosting.Net - The Forum Hosting Specialists
|
|
|
Machina
New Member
Switzerland
74 Posts |
Posted - 29 November 2004 : 03:41:32
|
quote: Originally posted by Gremlin
This won't work on MySQL at all now. When releasing MOD's it's really a good idea to make sure they work with all the database types that Snitz supports.
Well I didn't intend to release a MOD, just a modification to help, even if it is only for sql server... Should I delete this topic? |
Machina ------- http://www.jaboulay.fr -------- Snitz based site: http://www.itu.int/YLinICTs MODS Used : TMPJ's Header Cell Image, Site Integration, Front Page News, News Events Calendar, Nikkol's Usergroups, Simple Slash, Avatar, File Sharing, Links |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 01 December 2004 : 23:09:40
|
No need to delete, but you should probably state in your post that its specifically for MS SQL otherwise you'll get people asking you to how to make it work with MySQL or Access questions :) |
Kiwihosting.Net - The Forum Hosting Specialists
|
|
|
Machina
New Member
Switzerland
74 Posts |
Posted - 06 December 2004 : 03:57:18
|
OK, done :-) |
Machina ------- http://www.jaboulay.fr -------- Snitz based site: http://www.itu.int/YLinICTs MODS Used : TMPJ's Header Cell Image, Site Integration, Front Page News, News Events Calendar, Nikkol's Usergroups, Simple Slash, Avatar, File Sharing, Links |
|
|
|
Topic |
|
|
|