国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

靜態(tài)生成中實現(xiàn)相關(guān)文章列表

2024-05-04 11:06:00
字體:
供稿:網(wǎng)友

以下是代碼片段:
<%
’=================================================
’過程名:ShowCorrelative
’作 用:顯示相關(guān)文章
’參 數(shù):ArticleNum ----最多顯示多少篇文章
’ TitleLen ----標(biāo)題最多字符數(shù),一個漢字=兩個英文字符
’=================================================
sub ShowCorrelative(ArticleNum,TitleLen)
dim rs,sql
dim strKey,arrKey,i
if ArticleNum>0 and ArticleNum<=100 then
sql="select top " & ArticleNum
else
sql="Select Top 5 "
end if
’利用"|"符號進行關(guān)鍵字的分割
strKey=mid(rs("Key"),2,len(rs("Key"))-2)
if instr(strkey,"|")>1 then
arrKey=split(strKey,"|")
strKey="((Key like ’%|" & arrKey(0) & "|%’)"
for i=1 to ubound(arrKey)
strKey=strKey & " or (Key like ’%|" & arrKey(i) & "|%’)"
next
strKey=strKey & ")"
else
strKey="(Key like ’%|" & strKey & "|%’)"
end if

sql= & " ID,Title,Author,date,Hits,L.LayoutFileName From Article A inner join Layout L on L.LayoutID=LayoutID Where Deleted=False and Passed=True and " & strKey & " and ID<>" & ID & " Order by ID desc"
Set rs= conn.execute(sql)
if TitleLen<0 or TitleLen>255 then TitleLen=50
if rs.bof and rs.Eof then
response.write "沒有相關(guān)文章"
else
do while not rs.eof
response.write "<a href=’" & rs("LayoutFileName") & "?ID=" & rs("ID") & "’ title=’文章標(biāo)題:" & rs("Title") & vbcrlf & "文章作者:" & rs("Author") & vbcrlf & "更新時間:" & rs("date") & vbcrlf & "點擊次數(shù):" & rs("Hits") & "’>" & gotTopic(rs("Title"),TitleLen) & "</a>"
rs.movenext
loop
end if
rs.close
set rs=nothing
end sub
%>


定義此過程后,然后再生成靜態(tài)頁面的文件中替換模板標(biāo)記
(如:htmlmake.asp)
以下是代碼片段:
pencat=replace(pencat,"[Xianghuanlist]",ShowCorrelative(5,20))

這樣就會生成具有相關(guān)文章列表的靜態(tài)頁了!
其中的紅色部分是核心的語句,可以只對其進行移植.

以下是代碼片段:
<%
’=================================================
’過程名:ShowCorrelative
’作 用:顯示相關(guān)文章
’參 數(shù):ArticleNum ----最多顯示多少篇文章
’ TitleLen ----標(biāo)題最多字符數(shù),一個漢字=兩個英文字符
’=================================================
sub ShowCorrelative(ArticleNum,TitleLen)
dim rs,sql
dim strKey,arrKey,i
if ArticleNum>0 and ArticleNum<=100 then
sql="select top " & ArticleNum
else
sql="Select Top 5 "
end if
’利用"|"符號進行關(guān)鍵字的分割
strKey=mid(rs("Key"),2,len(rs("Key"))-2)
if instr(strkey,"|")>1 then
arrKey=split(strKey,"|")
strKey="((Key like ’%|" & arrKey(0) & "|%’)"
for i=1 to ubound(arrKey)
strKey=strKey & " or (Key like ’%|" & arrKey(i) & "|%’)"
next
strKey=strKey & ")"
else
strKey="(Key like ’%|" & strKey & "|%’)"
end if

sql= & " ID,Title,Author,date,Hits,L.LayoutFileName From Article A inner join Layout L on L.LayoutID=LayoutID Where Deleted=False and Passed=True and " & strKey & " and ID<>" & ID & " Order by ID desc"
Set rs= conn.execute(sql)
if TitleLen<0 or TitleLen>255 then TitleLen=50
if rs.bof and rs.Eof then
response.write "沒有相關(guān)文章"
else
do while not rs.eof
response.write "<a href=’" & rs("LayoutFileName") & "?ID=" & rs("ID") & "’ title=’文章標(biāo)題:" & rs("Title") & vbcrlf & "文章作者:" & rs("Author") & vbcrlf & "更新時間:" & rs("date") & vbcrlf & "點擊次數(shù):" & rs("Hits") & "’>" & gotTopic(rs("Title"),TitleLen) & "</a>"
rs.movenext
loop
end if
rs.close
set rs=nothing
end sub
%>


定義此過程后,然后再生成靜態(tài)頁面的文件中替換模板標(biāo)記
(如:htmlmake.asp)
以下是代碼片段:
pencat=replace(pencat,"[Xianghuanlist]",ShowCorrelative(5,20))

這樣就會生成具有相關(guān)文章列表的靜態(tài)頁了!
其中的紅色部分是核心的語句,可以只對其進行移植.

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 平安县| 休宁县| 济阳县| 天全县| 海晏县| 五大连池市| 新丰县| 城固县| 安陆市| 新津县| 西峡县| 东源县| 西乡县| 龙泉市| 东海县| 栾城县| 南部县| 云霄县| 马龙县| 左云县| 新化县| 尉犁县| 乌海市| 青阳县| 星子县| 呼和浩特市| 什邡市| 永城市| 闵行区| 卢湾区| 且末县| 綦江县| 信阳市| 观塘区| 揭阳市| 昭苏县| 兴安盟| 油尖旺区| 玛沁县| 麻江县| 察隅县|