国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 巍山| 建阳市| 海原县| 枝江市| 闽清县| 邢台市| 鄂州市| 神农架林区| 都昌县| 潼南县| 通辽市| 丰县| 泊头市| 闻喜县| 宝坻区| 泸水县| 綦江县| 铁岭市| 玛纳斯县| 宁河县| 富宁县| 饶阳县| 科尔| 泗水县| 金沙县| 屯门区| 新晃| 渭源县| 育儿| 阿巴嘎旗| 乐清市| 车致| 柞水县| 郴州市| 金坛市| 灵山县| 启东市| 北宁市| 淮南市| 舞钢市| 长寿区|