Jump to Last Post Permalink - Postet den (7748 Views)
Support Moderator
Shaggy
Innlegg: 6780
6780
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:
Code:
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.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
   
 Sidestørrelse 
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
Actually, thinking about it las night, would it really be that big a deal if this script redirected you to the last actual reply in a topic rather than the last edited reply? The main purpose for this script is for external links, which people unfamiliar with Snitz would be expecting to take them to the last actual post, and subscription mails which will only get sent out upon a new post.
All I need now is someone with a base install to test the above for me wink
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
New Member
Riccardo
Innlegg: 86
86
i can test it ..but i haven't a fresh or new topic.asp<
http://www.peperonciniamoci.it peppers and peppers and peppers (working on an international version)
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
Cool, cheers, man smile Be sure to back up your topic.asp file first, of course.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
New Member
Riccardo
Innlegg: 86
86
ok tested..but i don't see big differences from the regular work of topic.asp
could you explain me better the purpose of that code?<
http://www.peperonciniamoci.it peppers and peppers and peppers (working on an international version)
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
Instead of linking to the last post of a topic using topic.asp?TOPIC_ID=x&whichpage=-1&REPLY_ID=y which will bring you to a specified reply (y), you can now do so using topic.asp?TOPIC_ID=x&whichpage=-1 which will always bring you to the actual last reply made in a topic.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
New Member
Riccardo
Innlegg: 86
86
so you save time for this operation now?
anyway the code work perfectly. Tested with reply and notifications..<
http://www.peperonciniamoci.it peppers and peppers and peppers (working on an international version)
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
bigsmile Got a link 'til I have a look?
<edit> By the way, what database did you test it on? </edit>

<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
New Member
Riccardo
Innlegg: 86
86
yes you can..it a test forum in italian. the firts row is black 'cause i was testing a css style.
you find it here.. links removed by ruirib at user's request Database? ACCESS<
http://www.peperonciniamoci.it peppers and peppers and peppers (working on an international version)
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
D'oh! It's actually linking to the first reply. I've made some changes to me code above, in green, which should fix that.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
New Member
Riccardo
Innlegg: 86
86
i've modified..still the same result? tell me 'cause i don't see differences.. :(<
http://www.peperonciniamoci.it peppers and peppers and peppers (working on an international version)
Du må legge inn en melding