Question
building a cfc that creates an RSS feed
I am attempting to build a cfc that will create an RSS feed
for me. my thought is that i feed i pass in a query object, the
feed title, link and description and then the names of the query
feilds that corrrespond to the item title, link and description.
that way the cfc would loop through the passed query and build each <item> with the correct data for title, link and description based on the feilds from the database which were identified in the CFC arguments. for instance, lets say i have a db table with news stories that looks like this:
tblStories
ID int PK
Title char 30
Link char 50
Description char 100
then i would invoke my cfc like this:
<CFQUERY name="stories">
SELECT *
FROM tblStories
</CFQUERY
<cfobject component="RSS_build" name="rssObj" />
<cfinvoke component="#variables.rssObj#" method="buildRSS" returnvariable="returnString">
<cfinvokeargument name="FeedQuery" value="#stories#">
<cfinvokeargument name="feedtitle" value="My news Feeds">
<cfinvokeargument name="feedLink" value=" http://www.mynewsfeeds.com/index.cfm?RSS=true">
<cfinvokeargument name="feedDescription" value="List of the items features on the homepage of mynewsfeeds.com">
<cfinvokeargument name="itemtitleField" value="Title">
<cfinvokeargument name="itemlinkField" value="Link">
<cfinvokeargument name="itemdescriptionField" value="Description">
</cfinvoke>
Then inside my CFC is where this gets kind of tricky. when i want to look through the passed query i am nto sure how i would access the feilds i want.
<cfloop query="mypassedQuery">
<title>mypassedquery.#arguments.itemtitleField#</title>
</cfloop>
but this outputs mypassedquery.Title. instead ov actually finding the value of mypassedquery.Title.
am i totally goign about this the wrong way? is there a better way to do this?
that way the cfc would loop through the passed query and build each <item> with the correct data for title, link and description based on the feilds from the database which were identified in the CFC arguments. for instance, lets say i have a db table with news stories that looks like this:
tblStories
ID int PK
Title char 30
Link char 50
Description char 100
then i would invoke my cfc like this:
<CFQUERY name="stories">
SELECT *
FROM tblStories
</CFQUERY
<cfobject component="RSS_build" name="rssObj" />
<cfinvoke component="#variables.rssObj#" method="buildRSS" returnvariable="returnString">
<cfinvokeargument name="FeedQuery" value="#stories#">
<cfinvokeargument name="feedtitle" value="My news Feeds">
<cfinvokeargument name="feedLink" value=" http://www.mynewsfeeds.com/index.cfm?RSS=true">
<cfinvokeargument name="feedDescription" value="List of the items features on the homepage of mynewsfeeds.com">
<cfinvokeargument name="itemtitleField" value="Title">
<cfinvokeargument name="itemlinkField" value="Link">
<cfinvokeargument name="itemdescriptionField" value="Description">
</cfinvoke>
Then inside my CFC is where this gets kind of tricky. when i want to look through the passed query i am nto sure how i would access the feilds i want.
<cfloop query="mypassedQuery">
<title>mypassedquery.#arguments.itemtitleField#</title>
</cfloop>
but this outputs mypassedquery.Title. instead ov actually finding the value of mypassedquery.Title.
am i totally goign about this the wrong way? is there a better way to do this?