0

In 30: Yahoo Pipes in ColdFusion

In 30

I like to spend some time writing proof of concept (POC) code. If such an experiment works I will often use it in an application and write it properly. Like many I have been impressed with the Yahoo Pipes. At a basic level Yahoo Pipes puts together two or more RSS feeds. Here I'll show how to do the backend in CF.

Ok first I made a pipe for myself of Ben Forta and Ray Camden's blog feeds which you can see here.

So, CF 7 does not handle RSS feeds natively but fortunately Ray Camden (does the man ever sleep? :)) has written a RSS.cfc that will read and write feeds. So with that downloaded I created an array of feeds.


Next lets create an object of RSS and then loop over that array and put the results of the feed in an array.


So now we have an array with a query of feeds but we really want to make one query. Time to step up Query-of-Queries! And the UNION operator.  Though one limitation is that Q-o-Q's need to refer to a query that does not have a dot in it. D'oh. However, the code below will get around that by setting a variable to the array with the query. Not fully sustainable but this is a POC.

Not the qry1.[date] notation to get around reserved words in Query-of-Queries.

Now a little outputting:

And the concept has been proved!

Full code:

 
 

tags:
In 30
Matthew Reinbold said:
 
You mention that copying the queries to a variable for use in a QofQ is only workable as a Proof of Concept. Considering that what I was trying to do before - a set of loops - was quite a bit more complicated this seems like an elegant solution.

If this wasn't POC how would you avoid copying to a separate variable?
 
posted 405 days ago
Add Comment Reply to: this comment OR this thread
 
 
Matthew -- It was the first solition I thought of and it seemed an ugly way to do it with the switch and case statements. However, thinking about it more I can't think of an easier solution so I say go for it!
 
posted 404 days ago
Add Comment Reply to: this comment OR this thread
 
Tighe K. Lory said:
 
I am in the process of using your Yahoo Pipes Example in Coldfusion, and have come up with a way of not using a case statement.

Just replace your cfquery with this and it will dynamically create the variables, and will also allow the addition of more feeds without adding cases:




SELECT qry#variables.i#.title,
qry#variables.i#.[date],
qry#variables.i#.description,
qry#variables.i#.link
FROM qry#variables.i#

UNION


ORDER BY [date] desc

 
posted 149 days ago
Add Comment Reply to: this comment OR this thread
 
Tighe K. Lory said:
 
Woops, it stripped out the CFML! I hope this works!

<cfquery name="pipeSelect" dbtype="query">
<cfloop from="1" to="#arrayLen(variables.arFeeds)#" index="variables.i">
   <cfset "qry#variables.i#" = arEntries[variables.i]>
   SELECT qry#variables.i#.title,
    qry#variables.i#.[date],
    qry#variables.i#.description,
    qry#variables.i#.link
   FROM qry#variables.i#
<cfif variables.i neq arrayLen(variables.arFeeds)>
UNION
</cfif>
</cfloop>
ORDER BY [date] desc
</cfquery>
 
posted 149 days ago
Add Comment Reply to: this comment OR this thread
 
 
@Tighe: Very nice!
 
posted 148 days ago
Add Comment Reply to: this comment OR this thread
 

Search

Sam  Farmer