无忧CMS如何调用外站数据?如何在一个网站调用5ucms的首页或者文章栏目?也许看过此文,你会觉得,一切是那么简单~~
本站首页以及文章页面右侧显示的内容就是通过这个RSS读取功能做出来的,与js调用相比,它更具有seo可塑性。实现原理如下:
(本功能在原无忧CMS论坛jenfy朋友制作的RSS源函数基础上稍作修改,可以实现任意无忧CMS任意页面调用外站数据)
1,在inc/function.asp中增加以下内容:
Function readrss(xmlseed)
dim xmlDoc
dim http
Dim title_s
Dim item,title,link,str
Dim i
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET",xmlseed,False
http.send
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.Async=False
xmlDoc.ValidateOnParse=False
xmlDoc.Load(http.ResponseXML)
Set item=xmlDoc.getElementsByTagName("item")
if item.Length<=1 then
else
For i=0 to 9 '调出最新10条数据,可自己修改
Set title=item.Item(i).getElementsByTagName("title")
Set link=item.Item(i).getElementsByTagName("link")
Dim author,pubDate
Set author=item.Item(i).getElementsByTagName("author")
Set pubDate=item.Item(i).getElementsByTagName("pubDate")
Dim Authorpost:Authorpost=author.Item(0).Text
title_s =title.Item(0).Text
if (len(title_s)>12) then
title_s=left(title.Item(0).Text,14)&"" '控制文章标题字数为14个字,可自己修改
end if
str = str & "<li><a href="""& link.Item(0).Text &""" title='"&Authorpost&"发表了"&title.Item(0).Text&"' target='_blank'>"& title_s &"</a></li>"
readrss = str
Next
end if
End Function
Dim post
post=readrss("http://www.csshaier.com/post/plugs/rss.asp") '引号里面是rss源地址
2、在首页或者任意合适的页面用{sys:post}调用即可!演示见本站。