Yesterday I posted a reminder that ColdFusion 11 developers can stop using the old "CFCs for Tags" feature that provided support for certain things in script. I mentioned that everything could be used in cfscript now and that the old CFCs were (sometimes, not always) a bit buggy.

Brad Wood suggested I actually provide an example of this and I thought it was a good idea. I wrote up two quick demos that demonstrate the new syntax. This isn't super deep or anything, but hopefully it gives you a basic idea of how this new syntax looks. First, an example of a few different tags:


cfhttp(url="",result="cnnReq",method="post") {

cfsearch(collection="test1", criteria="cat", name="searchResults");

cffeed(action="read", source="", query="feed");

Make note of how you can't use a result (ie, foo = goo()) in any of these calls and instead use an argument. That could be easily fixed and should be. Second, note how child tags are handled in the second cfhttp call. I don't have anything to add to it, but as I said, just note the syntax.

For the heck of it, I then wrote a second demo. This one takes an array of RSS URLs and uses cfthread to fetch them in parallel. It then merges the resultant queries and sorts them. A mini-aggregator if you will.

feeds = ["","",""];
threads = [];

//for each feed, use a thread to fetch rss
feeds.each(function(f,x) {
	var name = "get_#x#";
	cfthread(name=name,feed=f) {
		cffeed(action="read", source=attributes.feed, query="feed");
		thread.feed = feed;

//copy thread queries out and create sql merge statement
sql = "";
feeds.each(function(f,x) {
	variables["feed#x#"] = cfthread["get_#x#"].feed;
	if(x > 1) {
		sql &= " union ";
	sql &= "select * from feed#x#";
merged = queryExecute(sql,{},{dbtype:"query"});
//credit Vince Collins:
merged = queryExecute("select content, title, rsslink, cast(publisheddate as date) as publisheddate from merged order by publisheddate desc", {}, {dbtype:"query"});

I hope this helps!