以下是代碼片段: <% '================================================= '過程名:ShowCorrelative '作用:顯示相關文章 '參數:ArticleNum ----最多顯示多少篇文章 ' TitleLen ----標題最多字符數,一個漢字=兩個英文字符 '================================================= 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 '利用|符號進行關鍵字的分割 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 沒有相關文章 else do while not rs.eof response.write <a href= ' & rs(LayoutFileName) & ?ID= & rs(ID) & ' title= '文章標題: & rs(Title) & vbcrlf & 文章作者: & rs(Author) & vbcrlf & 更新時間: & rs(date) & vbcrlf & 點擊次數: & rs(Hits) & '> & gotTopic(rs(Title),TitleLen) & </a> rs.movenext loop end if rs.close set rs=nothing end sub %> |
定義此過程後,然後再生成靜態頁面的文件中替換模板標記
(如:htmlmake.asp)
以下是代碼片段: pencat=replace(pencat,[Xianghuanlist],ShowCorrelative(5,20)) |
這樣就會生成具有相關文章列表的靜態頁了!
其中的紅色部分是核心的語句,可以只對其進行移植.
以下是代碼片段: <% '================================================= '過程名:ShowCorrelative '作用:顯示相關文章 '參數:ArticleNum ----最多顯示多少篇文章 ' TitleLen ----標題最多字符數,一個漢字=兩個英文字符 '================================================= 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 '利用|符號進行關鍵字的分割 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 沒有相關文章 else do while not rs.eof response.write <a href= ' & rs(LayoutFileName) & ?ID= & rs(ID) & ' title= '文章標題: & rs(Title) & vbcrlf & 文章作者: & rs(Author) & vbcrlf & 更新時間: & rs(date) & vbcrlf & 點擊次數: & rs(Hits) & '> & gotTopic(rs(Title),TitleLen) & </a> rs.movenext loop end if rs.close set rs=nothing end sub %> |
定義此過程後,然後再生成靜態頁面的文件中替換模板標記
(如:htmlmake.asp)
以下是代碼片段: pencat=replace(pencat,[Xianghuanlist],ShowCorrelative(5,20)) |
這樣就會生成具有相關文章列表的靜態頁了!
其中的紅色部分是核心的語句,可以只對其進行移植.