T O P I C R E V I E W |
Shaggy |
Posted - 21 September 2005 : 13:05:43 After some recent discussions about it, I've been working on modifying the jump to last post feature so it does not need to pass the REPLY_ID through the querystring, effectively allowing you to create permanent links that will always take you to the latest post in a topic. Here's what I have so far:if mypage=-1 then
strSql1="SELECT REPLY_ID"
strSql2=" FROM "&strActivePrefix&"REPLY "
strSql3=" WHERE TOPIC_ID="&Topic_ID
if AdminAllowed=0 then
strSql3=strSql3&" AND (R_STATUS<"
if Moderation="Y" then strSql3=strSql3&"2" else strSql3=strSql3&"3"
strSql3=strSql3&" OR R_AUTHOR="&MemberID&")"
end if
strSql4=" ORDER BY R_DATE ASC"
set rsReplies=server.createobject("ADODB.Recordset")
if strDBType="mysql" then
rsReplies.open strSql1&strSql2&strSql3&strSql4,my_Conn,adOpenStatic,adLockReadOnly,adCmdText
if rsReplies.eof then
iReplyCount=-1
strwhichpage=""
else
arrReplyData=rsReplies.getrows(adGetRowsRest)
iReplyCount=ubound(arrReplyData,2)
if len(request.querystring("REPLY_ID"))>0 then LastPostReplyID=clng(request.querystring("REPLY_ID")) else LastPostReplyID=cLng(arrReplyData(0,iReplyCount))
end if
if iReplyCount>-1 then
for iReply=0 to iReplyCount
intReplyID=arrReplyData(0,iReply)
if LastPostReplyID=intReplyID then
intPageNumber=((iReply+1)/strPageSize)
if intPageNumber>clng(intPageNumber) then intPageNumber=clng(intPageNumber)+1
strwhichpage="whichpage="&intPageNumber&"&"
exit for
end if
next
end if
else
rsReplies.cachesize=strPageSize
rsReplies.pagesize=strPageSize
rsReplies.open strSql1&strSql2&strSql3&strSql4,my_Conn,adOpenStatic,,adCmdText
if len(request.querystring("REPLY_ID"))>0 then
LastPostReplyID=clng(request.querystring("REPLY_ID"))
else
rsReplies.movelast
LastPostReplyID=cLng(rsReplies("REPLY_ID"))
rsReplies.movefirst
end if
rsReplies.find="REPLY_ID="&LastPostReplyID&""
if not (rsReplies.eof or rsReplies.bof) then
if rsReplies.absolutepage>1 then strwhichpage="whichpage="&rsReplies.absolutepage&"&"
else
strwhichpage = ""
end if
end if
rsReplies.close
set rsReplies=nothing
my_Conn.close
set my_Conn=nothing
response.redirect("topic.asp?"&strwhichpage&"TOPIC_ID="&Topic_ID&"#"&LastPostReplyID&"")
response.end
end if That replaces the if statement beginning on line 202 of a fresh, v3.4.05 topic.asp. Note that I haven't tested this yet mainly because I don't have a clean Snitz that I can test it on but also because I've already encountered a problem in that the code above will always take you to the last actual reply to a topic without taking into account any replies that may have been edited after the last actual reply. I'm about to switch over to me other job for the evening but wanted to post this here first so's ye could see where I'm going with it and maybe offer some insights as to how to get around the problem I mentioned.
< |
15 L A T E S T R E P L I E S (Newest First) |
Shaggy |
Posted - 24 April 2008 : 05:55:11 You're welcome, buddy
< |
Astralis |
Posted - 24 April 2008 : 05:53:16 Excellent! It's working great! Thank you for helping me.
I figured that green line was probably a leftover from some other discussion.< |
Shaggy |
Posted - 24 April 2008 : 05:47:40 Me either, but it was a while ago now I think Davio added that line in when adding this to the base code. But, yeah, just replace that chunk of code with mine, taking care to back up topic.asp first, just in case.
< |
Astralis |
Posted - 24 April 2008 : 05:33:12 Shaggy,
I never did figure out what that green line is for, whether that is the only line that needs changed or something else.
When I looked around line 202 of topic.asp, I found the following code. Are you saying I should replace it entirely with everything you have?
if mypage = -1 and Request.QueryString("REPLY_ID") <> "" then
strSql1 = "SELECT REPLY_ID "
strSql2 = "FROM " & strActivePrefix & "REPLY "
strSql3 = "WHERE TOPIC_ID = " & Topic_ID & " "
' DEM --> if not a Moderator, all unapproved posts should not be viewed.
if AdminAllowed = 0 then
strSql3 = strSql3 & "AND (R_STATUS < "
if Moderation = "Y" then
' Ignore unapproved/rejected posts
strSql3 = strSql3 & "2 "
else
' Ignore any previously rejected topic
strSql3 = strSql3 & "3 "
end if
strSql3 = strSql3 & "OR R_AUTHOR = " & MemberID & ") "
end if
strSql4 = "ORDER BY R_DATE ASC "
if strDBType = "mysql" then
set rsReplies = Server.CreateObject("ADODB.Recordset")
rsReplies.open strSql1 & strSql2 & strSql3 & strSql4, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if rsReplies.EOF then
iReplyCount = ""
else
arrReplyData = rsReplies.GetRows(adGetRowsRest)
iReplyCount = UBound(arrReplyData, 2)
rREPLY_ID = 0
end if
LastPostReplyID = cLng(Request.QueryString("REPLY_ID"))
if iReplyCount <> "" then
for iReply = 0 to iReplyCount
intReplyID = arrReplyData(rREPLY_ID,iReply)
if LastPostReplyID = intReplyID then
intPageNumber = ((iReply+1)/strPageSize)
if intPageNumber > cLng(intPageNumber) then
intPageNumber = cLng(intPageNumber) + 1
end if
strwhichpage = "whichpage=" & intPageNumber & "&"
exit for
end if
next
else
strwhichpage = ""
end if
rsReplies.Close
set rsReplies = nothing
else
set rsReplies = Server.CreateObject("ADODB.Recordset")
rsReplies.cachesize = strPageSize
rsReplies.pagesize = strPageSize
rsReplies.open strSql1 & strSql2 & strSql3 & strSql4, my_Conn, adOpenStatic, adLockReadOnly, adCmdText
LastPostReplyID = cLng(Request.QueryString("REPLY_ID"))
rsReplies.Find = "REPLY_ID=" & LastPostReplyID & ""
if not (rsReplies.EOF or rsReplies.BOF) then
if rsReplies.absolutepage > 1 then strwhichpage = "whichpage=" & rsReplies.absolutepage & "&"
else
strwhichpage = ""
end if
rsReplies.Close
set rsReplies = nothing
end if
Response.Redirect("topic.asp?" & strwhichpage & "TOPIC_ID=" & Topic_ID & "#" & LastPostReplyID & "")
Response.End
end if
< |
Shaggy |
Posted - 13 September 2006 : 12:18:55 Here's the final version of this code that was included in Snitz v3.4.06, released today:if mypage=-1 then
strSql="SELECT REPLY_ID FROM "&strActivePrefix&"REPLY WHERE TOPIC_ID="&Topic_ID
if AdminAllowed=0 then
strSql=strSql&" AND (R_STATUS<"
if Moderation="Y" then strSql=strSql&"2" else strSql=strSql&"3"
strSql=strSql&" OR R_AUTHOR="&MemberID&")"
end if
strSql=strSql&" ORDER BY R_DATE ASC"
set rsReplies=server.createobject("ADODB.Recordset")
if strDBType="mysql" then rsReplies.open strSql,my_Conn,adOpenForwardOnly,adLockReadOnly,adCmdText else rsReplies.open strSql,my_Conn,adOpenStatic,adLockReadOnly,adCmdText
if not rsReplies.eof then
arrReplyData=rsReplies.getrows(adGetRowsRest)
iReplyCount=ubound(arrReplyData,2)
Reply_ID=trim(chkString(request.querystring("REPLY_ID"),"sqlstring"))
if len(Reply_ID)>0 and isnumeric(Reply_ID) then
LastPostReplyID=clng(Reply_ID)
for iReply=0 to iReplyCount
intReplyID=arrReplyData(0,iReply)
if LastPostReplyID=intReplyID then
intPageNumber=((iReply+1)/strPageSize)
exit for
end if
next
else
LastPostReplyID=clng(arrReplyData(0,iReplyCount))
intPageNumber=((iReplyCount+1)/strPageSize)
end if
if intPageNumber>clng(intPageNumber) then intPageNumber=clng(intPageNumber)+1
strwhichpage="whichpage="&intPageNumber&"&"
else
strWhichpage=""
end if
rsReplies.close
set rsReplies=nothing
my_Conn.close
set my_Conn=nothing
response.redirect "topic.asp?"&ArchiveLink&strwhichpage&"TOPIC_ID="&Topic_ID&SearchLink&"&#"&LastPostReplyID
response.end
end if < |
tribaliztic |
Posted - 09 March 2006 : 08:27:52 hehe, I'm using SHN version. Maybe it's from there. I thought it was basecode. Now when that is cleared you can take a look at my latest thread ;) < |
Shaggy |
Posted - 09 March 2006 : 08:15:05 There is no such button on topic.asp, unless you have it modded in, and this modification does not add one.
< |
tribaliztic |
Posted - 09 March 2006 : 08:08:23 A button where you can jump to the last post after opening the thread in topic.asp =) In admin options, under Feature Configuration I have a on/off-switch for "Show Jump To Last Post Link"... < |
Shaggy |
Posted - 09 March 2006 : 07:22:25 No - what button?
< |
tribaliztic |
Posted - 09 March 2006 : 07:21:08 Ah, that's right.. I saw that yesterday! My day haven't been that good to me so far =)
But isn't there a button also? < |
Shaggy |
Posted - 09 March 2006 : 07:17:14 It shouldn't be; if you read through this topic, you'll see that this is just a modification to the existing script that will allow you to jump to the last posted reply in a topic with th need to pass the REPLY_ID through the querystring.
< |
tribaliztic |
Posted - 09 March 2006 : 07:03:35 ah, there you go =) No errors! But I see no link even though the option is selected in admin options. Where should it be located on the topic.asp page? =) < |
Shaggy |
Posted - 09 March 2006 : 06:57:42 Another & went walkabout in Rui's last posting of the code which I've added back in; just copy the updated redirect line from my last posting of it and all should be well.
< |
tribaliztic |
Posted - 09 March 2006 : 06:52:37 I suppose this is the correct translation:
Microsoft VBScript compilation error '800a0401' Expected end of statement
Where should I put the & ? =) < |
Shaggy |
Posted - 09 March 2006 : 06:45:24 Well, for starters, the bloody & went for a walk again, thanks to the forum filtering out &#.
Secondly, can you translate that error into English for us?
< |
|
|