ColdFusion MX 7的CFFEED组件/自定义标记?

ColdFusion MX 7的CFFEED组件/自定义标记?,coldfusion,rss,feed,cffeed,Coldfusion,Rss,Feed,Cffeed,我正在一个客户的网站上工作,更新到ColdFusion 8不是一个选项。我想要的是通过自定义标记或组件实现类似于CF8的CFFEED功能的东西,如果已经存在某种东西,我并不特别热衷于编写自己的阅读器/解析器 我需要从博客阅读RSS2提要,并显示标题、描述和链接。最好我能设置大约5-10分钟的缓存,这样我就不会重击feed(我从feed中获取的信息将显示在高流量站点上)。如果您正在寻找一些现成的东西,Riafoge上有一些项目,快速搜索会发现这两个,但我猜您可以找到更多: 如果你打算自己滚动(

我正在一个客户的网站上工作,更新到ColdFusion 8不是一个选项。我想要的是通过自定义标记或组件实现类似于CF8的CFFEED功能的东西,如果已经存在某种东西,我并不特别热衷于编写自己的阅读器/解析器


我需要从博客阅读RSS2提要,并显示标题、描述和链接。最好我能设置大约5-10分钟的缓存,这样我就不会重击feed(我从feed中获取的信息将显示在高流量站点上)。

如果您正在寻找一些现成的东西,Riafoge上有一些项目,快速搜索会发现这两个,但我猜您可以找到更多:

如果你打算自己滚动(我知道你说你不喜欢),你就不能这样请求提要:

<cfhttp 
  url = "http://example.com" 
  resolveurl="no"
  throwOnError = "yes"
  timeout = "10" >
</cfhttp>

并分析结果:

<cfset feedData = CFHTTP.FileContent>
<cfset xmlData = XMLParse(feedData)>

循环通过:

<cfset result = queryNew("title,description")>  
<cfset items = xmlSearch(xmlData,"//*[local-name() = 'item']")>

<cfloop index="x" from="1" to="#arrayLen(items)#">

    <cfif structKeyExists(items[x],"title")>
        <cfset node.title = items[x].title.XmlText>
    <cfelse>
        <cfset node.title = "">
    </cfif>

    <cfif structKeyExists(items[x],"description")>
        <cfset node.description = items[x].description.XmlText>
    <cfelse>
        <cfset node.description = "">
    </cfif>

    <cfset queryAddRow(result)>
    <cfset querySetCell(result,"title",node.title)>
    <cfset querySetCell(result,"description",node.description)>

</cfloop>
<cfif structKeyExists(items[x],"guid")>
    <cfset node.guid = items[x].guid.XmlText>
<cfelse>
    <cfset node.guid = "">
</cfif>

<cfset querySetCell(result,"guid",node.guid)>

输出:

<cfoutput query="result">
    <ul>
        <li><strong>#title#</strong> - #description#</li>
    </ul>
</cfoutput>

  • #标题#-说明#

显然未经测试,但仍然是一个想法。使用类似的东西来获取我最新的美味书签。至于缓存,有几种不同的方法来处理。我可能会运行一个计划任务来点击这个文件,并将输出写入包含的单独文件。我确信有更好的方法,但我认为这是一个快速的方法。

我知道这有点晚了,但在我的工作中遇到了这种情况(Coldfuison 7,不会升级)。但也需要从我们网站的嵌入位置链接回原始帖子

只需在上面的伟大答案上再添加一点,您可以添加此链接以返回到文章(在我们的例子中是关于tumbler的) 在循环中通过:

<cfset result = queryNew("title,description")>  
<cfset items = xmlSearch(xmlData,"//*[local-name() = 'item']")>

<cfloop index="x" from="1" to="#arrayLen(items)#">

    <cfif structKeyExists(items[x],"title")>
        <cfset node.title = items[x].title.XmlText>
    <cfelse>
        <cfset node.title = "">
    </cfif>

    <cfif structKeyExists(items[x],"description")>
        <cfset node.description = items[x].description.XmlText>
    <cfelse>
        <cfset node.description = "">
    </cfif>

    <cfset queryAddRow(result)>
    <cfset querySetCell(result,"title",node.title)>
    <cfset querySetCell(result,"description",node.description)>

</cfloop>
<cfif structKeyExists(items[x],"guid")>
    <cfset node.guid = items[x].guid.XmlText>
<cfelse>
    <cfset node.guid = "">
</cfif>

<cfset querySetCell(result,"guid",node.guid)>

在输出中:

<a href="#guid#">#title#</a>

我相信你也可以用“链接”来代替“guid”,但这对我来说很有效。 我希望这可以帮助其他需要链接的人。我对ColdFusion很陌生, 也许有更好的方法(在旧版本的CF上)可以做到这一点