Skip to content

Setup Your Applicatoin

Jorge Reyes edited this page Jun 3, 2015 · 2 revisions

Before you start feeding data into the plug-in we need to setup your application to be ready to handle the XML files. This is a very important process otherwise the character encoding may not work correctly so your XML may not display in peoples feed readers.

Create a xml sub-directory within the includes directory. This should be where the future feed XML files are stored.

+ApplicationRoot
|---+ includes
    |---+ xml

Create a file with the code below and save it as Layout.xml.cfm in the layouts directory. This layout will tell ColdBox how to correctly display XML content.

<cfset event.showdebugpanel("false")>
<cfcontent type="application/rss+xml"><cfoutput>#trim(renderView())#</cfoutput>
+ApplicationRoot
|---+ layouts
    |---+ Layout.xml.cfm

Create a new view file to display the RSS XML content with the code below. Name it vwDisplayFeed.cfm while saving it to the views directory.

<cfoutput>#rc.feedasxml#</cfoutput>

Then create another view file vwGenerateFeed.cfm, this will be used when generating or recompiling the feed.

<cfif rc.compileFeed>
  <h2>Congratulations the feed was successfully updated</h2>
<cfelse>
  <h2>There was a problem updating the feed</h2>
</cfif>

Edit your ColdBox ColdBox.xml.cfm file and update your layouts declaration to use the new XML friendly layout.

<--D<eclare Layouts for your application here-->
<Layouts>
  <--D<eclare the default layout, MANDATORY-->
  <DefaultLayout>Layout.Main.cfm</DefaultLayout>
  <--D<eclare XML layout for use with feeds-->
  <Layout file="Layout.xml.cfm" name="xml">
    <View>vwDisplayFeed</View>
  </Layout>
</Layouts>
Clone this wiki locally