添加新聞時自動添加關(guān)鍵字_風(fēng)訊Cms教程
我是先做抓取新聞時自動添加要害字后,想到手工添加新聞時也可以把這個功能用上去。所以兩段程序可以說是完全一樣的,只是應(yīng)用的場所不同~
請先備份:
Admin/Info/NewsWords.asp
下面開始修改:
1、打開Admin/Info/NewsWords.asp,拉到倒數(shù)第二行(也就是%>的前面),把下面的代碼貼上去。
'************************************
'author:lino
'把標(biāo)題與要害字表中的記錄匹配
'Start
'*************************
Function replaceKeywordByTitle(title)
Dim whereisKeyword,i,theKeywordOnNews
Dim keyword,rsRuleObj,theKeywordS
Set RsRuleObj = Conn.Execute("Select * from Routine")
do while Not RsRuleObj.Eof
keyword = RsRuleObj("name")
whereisKeyword = InStr(Lcase(title),Lcase(keyword))
if(whereisKeyword>0) then
if(theKeywordOnNews="") then
theKeywordOnNews=keyword
else
theKeywordOnNews=theKeywordOnNews&","&keyword
end if
end if
RsRuleObj.MoveNext
loop
'假如keyword的長度大于100,截去過長的
if(len(theKeywordOnNews)>99) then
theKeywordOnNews=left(theKeywordOnNews,99)
end if
replaceKeywordByTitle = theKeywordOnNews
End function
'**********************
'End
在同一頁面(即Admin/Info/NewsWords.asp)中找到
INewsAddObj("KeyWords") = Replace(Replace(Requst("KeywordText"),"""",""),"'","")
或約637行,把
INewsAddObj("KeyWords") = Replace(Replace(Requst("KeywordText"),"""",""),"'","")
換成
'************************************
'author:lino
'把調(diào)用replaceKeywordByTitle方法,過濾要害字
'假如用戶自定義了要害字,自動設(shè)置要害字不起作用
'Start
'*************************
Dim KeywordText
if (Request("KeywordText")="" or isempty(Request("KeywordText"))) then
KeywordText = replaceKeywordByTitle(ITitle)
else
KeywordText = Request("KeywordText")
end if
if KeywordText <> "" then
INewsAddObj("KeyWords") = Replace(Replace(KeywordText,"""",""),"'","")
end if
'End
'***********************************
- 最簡單的欄目切換方法(樣式系列之欄目切換篇2)
- 我也放個欄目切換代碼,簡簡單單的。
- 搜狐女性頻道幻燈效果(幻燈系列之flash特效篇)
- 有效控制新聞內(nèi)容的圖片的尺寸
- 現(xiàn)提供增加<目錄生成規(guī)則>的方法!
- 風(fēng)訊里面上下篇標(biāo)簽DIV模式下浮動的解決方法!
- 風(fēng)訊目錄路徑自由選擇的實(shí)現(xiàn)方法
- 新聞列表讀取內(nèi)容時去掉html代碼
- 添加文字廣告的解決方案!
- 發(fā)些滾動的代碼
- 標(biāo)題下的分隔線在4.0中如何設(shè)置,還有標(biāo)題的行間距
- 隨時更換模版、廣告等,無須重新生成整站,共享出來供討論
- 相關(guān)鏈接:
- 教程說明:
風(fēng)訊Cms教程-添加新聞時自動添加關(guān)鍵字
。