Created
July 2, 2015 20:26
-
-
Save stevewithington/03f15938fa0ca2e9fa79 to your computer and use it in GitHub Desktop.
ColdFusion/CFML CFFeed Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
These examples show how to consume and output a RSS feed using CFML's <cffeed> tag | |
More info: | |
* http://docs.lucee.org/reference/tags/feed.html | |
* https://wikidocs.adobe.com/wiki/display/coldfusionen/cffeed | |
---> | |
<cfoutput> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>CFFeed RSS Consumption Examples</title> | |
</head> | |
<body> | |
<section> | |
<h2>Mura CMS</h2> | |
<cfset feedURL = 'http://www.getmura.com/tasks/feed/?feedID=91B4E7A5-37AC-466A-ACDF6ABFD95ACCBD' /> | |
<!--- Will give you a query/recordset ---> | |
<cffeed query="feedRecordset" source="#feedURL#" /> | |
<!--- <cfdump var="#feedRecordset#" /> ---> | |
<!--- Example of looping over a recordset ---> | |
<cfif feedRecordset.recordcount> | |
<h3>CFFeed query="feedRecordset" Example</h3> | |
<ol class="feed-items"> | |
<cfloop query="#feedRecordset#"> | |
<li class="feed-item"> | |
<h4 class="feed-item-title">#title#</h4> | |
<div class="feed-item-pubdate"> | |
#publisheddate# | |
</div> | |
<div class="feed-item-content"> | |
#content# | |
</div> | |
<div class="feed-item-link"> | |
<a href="#rsslink#">#rsslink#</a> | |
</div> | |
</li> | |
</cfloop> | |
</ol> | |
<cfelse> | |
<h3>No feed items.</h3> | |
</cfif> | |
<hr /> | |
<!--- Will give you a struct of feed data ---> | |
<cffeed source="#feedURL#" action="read" name="feedStruct" /> | |
<!--- <cfdump var="#feedStruct#" /> ---> | |
<!--- Use the 'item' key to obtain the array of items to work with ---> | |
<!--- <cfdump var="#feedStruct.item#" /> ---> | |
<!--- Example of looping over an array of feed items ---> | |
<cfif ArrayLen(feedStruct.item)> | |
<h3>CFFeed action="read" Example</h3> | |
<ol class="feed-items"> | |
<cfloop array="#feedStruct.item#" index="i"> | |
<li class="feed-item"> | |
<h4 class="feed-item-title">#i.title#</h4> | |
<div class="feed-item-pubdate"> | |
#i.pubDate# | |
</div> | |
<div class="feed-item-content"> | |
#i.description.value# | |
</div> | |
<div class="feed-item-link"> | |
<a href="#i.link#">#i.link#</a> | |
</div> | |
</li> | |
</cfloop> | |
</ol> | |
<cfelse> | |
<h3>No feed items.</h3> | |
</cfif> | |
</section> | |
</body> | |
</html> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment