Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Overview

Building an iTunes feed is relatively straightforward in ColdFusion. The trick in FarCry Framework is knowing where to put the code. This example is taken directly from the webDU Developer Conference website.

Suitable for applications running FarCry Core 5.1+

Building a Feed

A feed is essentially a collection of content items, for example conference sessions.

Complete Code

./webskin/mxSession/feediTunes.cfm
<cfsetting enablecfoutputonly="true" /> 
<!--- @@Copyright: Copyright (c) 2009 Daemon Pty Limited. All rights reserved. --->
<!--- @@displayname: iTunes Feed --->
<!--- @@description: feeditunes --->
<!--- @@author: Geoffrey Bowers on 2009-05-29 --->

<!--- import tag libraries --->
<cfimport taglib="/farcry/core/tags/webskin" prefix="skin" />

<!--- deactivate the tray --->
<cfset request.bHideContextMenu = true />

<!--- create local objects --->
<cfset oSession = application.fapi.getContentType("mxSession") />
<cfset oSpeaker = application.fapi.getContentType("mxSpeaker") />

<!--- get relevant sessions for podcast --->
<cfquery datasource="#application.dsn#" name="qSessions" maxrows="250">
SELECT objectid FROM mxSession
WHERE status = 'approved'
AND MP3PODCAST <> ''
ORDER BY datetimelastupdated DESC
</cfquery>


<cfoutput><?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.apple.com/itunes/store/podcaststechspecs.html -->
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
	<title>WebDU 2009</title>
	<link>http://webdu.com.au</link>
	<language>en-us</language>
	<copyright>&##x2117; &amp; &##xA9; 2009 Daemon Pty Ltd</copyright>
	<itunes:subtitle>Sessions from the mighty WebDU 2009 Conference.</itunes:subtitle>
	<itunes:author>Rob Rohan</itunes:author>
	<itunes:summary>
The premier Antipodean web technology conference, webDU encompasses a broad spectrum of 
web technologies and techniques. webDU is the must attend annual event for anyone building 
a better Internet.
	</itunes:summary>
	<description>
The premier Antipodean web technology conference, webDU encompasses a broad spectrum of
web technologies and techniques. webDU is the must attend annual event for anyone building 
a better Internet.
	</description>

	<itunes:owner>
		<itunes:name>Daemon.com.au</itunes:name>
		<itunes:email>geoff@daemon.com.au</itunes:email>
	</itunes:owner>
	
	<image>
		<url>http://s3.amazonaws.com/webdu2009/podcast144_400.jpg</url>
		<title>WebDU 2009</title><!-- should match channel title -->
		<link>http://webdu.com.au</link>
	</image>
	
	<itunes:image href="http://s3.amazonaws.com/webdu2009/podcast600_600.jpg" />

	<itunes:category text="Technology">
		<itunes:category text="Gadgets"/>
		<itunes:category text="Tech News"/>
		<itunes:category text="Software How-To"/>
	</itunes:category>
	
	<itunes:explicit>no</itunes:explicit>
	<!-- //////////////////////////////////////////////////////////////////// -->
</cfoutput>

<cfoutput query="qSessions">
	<cftry>
	<cfset stSession = osession.getdata(objectid=qSessions.objectid) />
	<cfset stSpeaker = ospeaker.getdata(objectid=stsession.aSpeakerID[1]) />
	<item>
		<title>#xmlFormat(stsession.title)#</title>
		<pubDate>#dateformat(stsession.datetimelastupdated, "dddd, dd mmmm yyyy")# #timeFormat(stsession.datetimelastupdated, "medium")#</pubDate>
		<enclosure url='#stsession.mp3podcast#' <cfif isNumeric(stsession.medialength) AND stsession.medialength gt 0>length='#round(stsession.mediaLength)#' </cfif>type='#stsession.mediaType#' />
		<itunes:duration>#stsession.mediaDuration#</itunes:duration>
		<itunes:author>#xmlFormat(stspeaker.title)#</itunes:author>
		<guid>#stsession.mp3podcast#</guid>
	</item>
	<cfcatch>
		<!--- <cfdump var="#cfcatch#" /> --->
		<!--- suppress error in output --->
	</cfcatch>
	</cftry>
</cfoutput>

<cfoutput>

	<!-- /////////////////////////////////////////////// -->
</channel>
</rss>
</cfoutput>

<cfsetting enablecfoutputonly="false" />
  • No labels