Component CFFEED / Custom Tag for ColdFusion MX 7?

I work on a client site, and upgrading to ColdFusion 8 is not an option. What I'm looking for looks like CF8 CFFEED functionality with a custom tag or component, and I'm not particularly keen on writing my own reader / parser if something already exists.

I need to read in the RSS2 feed from the blog and display the title, description and link. Preferably, I could set the cache for about 5-10 minutes so that I do not clog the feed (the information that I pull from the feed will be displayed on a site with high traffic).

+3
source share
2 answers

- , RIAForge, , , :

http://cfrss.riaforge.org/

http://rssville.riaforge.org/

(, , , ), :

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

:

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

, , . , . , . , , , , . , , n , imo.

+7

, , (Coldfuison 7 ). -.

, , ( ) :

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

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

Output:

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

, "" "guid", . , - , . ColdFusion, ( CF).

0

Source: https://habr.com/ru/post/1714825/


All Articles