Faster isn't always better, but sometimes it is.
Using the CFFEED tag, I set up an RSS feed on a site in less than 5 minutes. The coding is dead simple and about as straight forward as you can get.
I have a CMS set up so that my content editors can add news items to the site. When they save the new item, the code below fires off and updates the RSS feed
Using the CFFEED tag, I set up an RSS feed on a site in less than 5 minutes. The coding is dead simple and about as straight forward as you can get.
I have a CMS set up so that my content editors can add news items to the site. When they save the new item, the code below fires off and updates the RSS feed
<!--- pull the 20 latest items ---> <cfquery name="getFeedDetails" datasource="#application.db#"> SELECT TOP (20) ID, Title, NewsText, NewsDate, linkData FROM myNewsTable ORDER BY NewsDate DESC </cfquery> <!--- Set up the structure with the feed meta data ---> <cfscript> myStruct = StructNew(); mystruct.link = "http://foobar.com"; myStruct.title = "FooBar News"; mystruct.description = "The authoritative online resource on how much wood a woodchuck would chuck if a woodchuck would chuck wood."; mystruct.pubDate = Now(); mystruct.version = "rss_2.0"; // Map the orders column names to the feed query column names. columnMapStruct = StructNew(); columnMapStruct.publisheddate = "NEWSDATE"; columnMapStruct.content = "NEWSTEXT"; columnMapStruct.title = "TITLE"; columnMapStruct.rsslink = "LINKDATA"; </cfscript> <!--- Create the feed ---> <cffeed action = "create" query= "#getFeedDetails#" properties="#mystruct#" columnMap="#columnMapStruct#" outputFile = "myRSS.xml" overwrite = "yes" xmlVar = "myXML">
That's all there is to it. myRSS.xml is a properly formatted feed file.