添加新闻时自动添加关键字-风讯CMS教程

来源:模板无忧 作者:lino 更新时间:2006-06-16 点击:

我是先做抓取新闻时自动添加要害字后,想到手工添加新闻时也可以把这个功能用上去。所以两段程序可以说是完全一样的,只是应用的场所不同~

请先备份:

Admin/Info/NewsWords.asp

下面开始修改:

1、打开Admin/Info/NewsWords.asp,拉到倒数第二行(也就是%>的前面),把下面的代码贴上去。

'************************************
'author:lino
'把标题与要害字表中的记录匹配
'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
'把调用replaceKeywordByTitle方法,过滤要害字
'假如用户自定义了要害字,自动设置要害字不起作用

'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
'***********************************

相关风讯CMS教程:
最新评论:
loading.. 评论加载中....
发表评论:不能超过250字节,请自觉遵守互联网相关政策法规.
  • 昵称: 验证:

最新风讯CMS教程