首页 > 网站 > 建站经验 > 正文

3.0增加上一篇、下一篇功能

2024-08-30 19:06:06
字体:
来源:转载
供稿:网友

使用方法:在需要调用的地方直接调用“{FS_上一篇}”和{FS_下一篇}标签就行了。

最终效果如:

上一篇:6日IT:赛门铁克公布完成Veritas收购交易
下一篇:日本政府出售中日本铁路价值46亿美元的股份

修改方法:

打开修改/admin/Refresh/Function.asp文件

第一步,在第一行<%后(也就是第二行)增加

dim NextTempStr,PreviousTempStr

第二步,在Content = GetVisionStr & Content这一行

在下面增加

Content = Replace(Content,"{FS_上一篇}",PreviousTempStr)
Content = Replace(Content,"{FS_下一篇}",NextTempStr)

第三步,找到Function RefreshNews(NewsRecordSetObj)

在下面增加

'生成上一篇下一篇
dim NowNewsID,NowClassID
NowNewsID = NewsRecordSetObj("ID")
NowClassID = NewsRecordSetObj("ClassID")
dim NextSql,NextRs,NextClassRs
'上一篇
NextSql = "Select TOP 1 id,NewsID,ClassID,Title,Path,FileName,FileExtName From News where ID < " & NowNewsID & " and ClassID = '" & NowClassID & "' order by id desc"
Set NextRs = Conn.Execute(NextSql)
If NextRs.eof or NextRs.bof Then
PreviousTempStr = "上一篇:没有了"
Else
Set NextClassRs = Conn.Execute("Select SaveFilePath,ClassEName from NewsClass where ClassID='" & NowClassID & "'")
If not NextRs.eof then PreviousTempStr = "上一篇:<a href='" & NextClassRs(0) & "/" & NextClassRs(1) & "/" & NextRs(5) & "." & NextRs(6) & "' title ='"&NextRs(3)&"'>"&NextRs(3)&"</a>"
NextClassRs.Close
Set NextClassRs = nothing
NextRs.Close
Set NextRs = nothing
End If
'下一篇
NextSql = "Select TOP 1 id,NewsID,ClassID,Title,Path,FileName,FileExtName From News where ID > " & NowNewsID & " and ClassID = '" & NowClassID & "' order by id"
Set NextRs = Conn.Execute(NextSql)
If NextRs.eof or NextRs.bof Then
NextTempStr = "下一篇:没有了"
Else
Set NextClassRs = Conn.Execute("Select SaveFilePath,ClassEName from NewsClass where ClassID='" & NowClassID & "'")
If not NextRs.eof then NextTempStr = "下一篇:<a href='" & NextClassRs(0) & "/" & NextClassRs(1) & "/" & NextRs(5) & "." & NextRs(6) & "' title ='"&NextRs(3)&"'>"&NextRs(3)&"</a>"
NextClassRs.Close
Set NextClassRs = nothing
NextRs.Close
Set NextRs = nothing
End If
'完成

讨论区: http://bbs.foosun.net/dispbbs.asp?boardID=22&ID=5366&page=1

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表