FoosunCMS-添加新闻时自动添加关键字:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: <span style="border:1px solid #000; float:right; text-align:center; padding:6px;"><strong>导航:</strong>返回上一页</span> <div style="clear:both;"></div> ...)
 
无编辑摘要
 
第1行: 第1行:
<span style="border:1px solid #000; float:right; text-align:center; padding:6px;"><strong>导航:</strong>[[FoosunCMS教程|返回上一页]]</span>
<span style="border:1px solid #000; float:right; text-align:center; padding:6px;"><strong>导航:</strong>[[FoosunCMS教程|返回上一页]]</span>
<div style="clear:both;"></div>
<div style="clear:both;"></div>
[[FoosunCMS]]-添加新闻时自动添加关键字








先做抓取新闻时自动添加[[关键字]]后,想到手工添加新闻时也可以把这个功能用上去。所以两段程序可以说是完全一样的,只是应用的场所不同~
请先备份:
Admin/Info/NewsWords.asp
下面开始修改:
*打开Admin/Info/NewsWords.asp,拉到倒数第二行(也就是%>的前面),把下面的代码贴上去。
<pre>
'************************************
'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
</pre>
在同一页面(即Admin/Info/NewsWords.asp)中找到
INewsAddObj("KeyWords") = Replace(Replace(Requst("KeywordText"),"""",""),"'","")
或约637行,把
INewsAddObj("KeyWords") = Replace(Replace(Requst("KeywordText"),"""",""),"'","")
换成
<pre>
'************************************
'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
'***********************************
</pre>





2010年6月4日 (五) 09:59的最新版本

导航:返回上一页

FoosunCMS-添加新闻时自动添加关键字



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

请先备份:

Admin/Info/NewsWords.asp

下面开始修改:

  • 打开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
'***********************************




参考来源[ ]