David Harris's Technology Blog

ColdFusion, Flex, and other stuff...   (and 338,183 hours, 14 mins in to my plan for global domination)

Search:

Calendar:

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Subscribe:

Enter your email address to subscribe to this blog.

Archives By Subject:

Tags:

action script adobe air ajax cfug coldfusion flash flex frameworks free software fxug general jpgmetadatareader mac off topic opensource papervision spry

Recent Entries:

No recent entries.

Top Posts:

Recent Comments:

Top Commenters:

My Links:

RSS:


Write your own ColdFusion tag

Disclaimer: this is completely un-recommended and don't do this, unless you work on the ColdFusion development team!

...now that's out of the way...

In my previous post I told you about the file that stores all the Tag definitions for CF tags. I was wrong, it stores MOST of them, as Todd Sharp pointed out here on Andy Jarrett's Blog (see comments)

If you check the "WEB-INF\cftags" folder, you will see the ".cfm" files cache,dump,savecontent and trace. I suspect these are the tags missing from that XML file...

If you see Jared's comment on Andy's blog: [quote]... they're technically custom tags that are globally available...[/quote]

Also there is the base "component.cfc" that all CFC's extend by default.

"So, what happens if you add your own '.cfm' file to this dir?" I asked myself...

So I created a "david.cfm" file and add the text "david".

Now I have a <cfdavid> tag! it takes no attributes and outputs "david" to the page.

CFML already has custom tags, and I would STRONGLY SUGGEST using these rather than what I have done just above!

I find it a bit interesting learning a little about how CF works, but I wouldn't suggest playing with the inner workings of CF to much! :-)

Related Blog Entries

Comments
That's pretty sweet, though. If I had access to those files I would totally play around with it :)
# Posted By Ben Nadel | 5/25/07 10:54 AM
Cool find. Potentially very dangerous though...
# Posted By Sam Farmer | 5/25/07 1:17 PM
@Sam, I don't really see the danger? You cannot over write the tags that are written in Java. Yeah you can remove the CF tags in there, but if some has that sort of access to your box there is a lot more to worry about :o)
# Posted By Andy J | 5/25/07 9:15 PM
@Andy -- More from a configuration point of view. Say you set up cfcool on one machine and then move some code to another machine and it doesn't work. Plus I always worry about doing anything to the CF Server configuration that is not documented.
# Posted By Sam Farmer | 5/25/07 11:56 PM
I wouldn't say it is dangerous, just highly un-recommended for the following reasons:

1. As Sam pointed out, if you move your app to another server, it's another thing to forget about in the process.
2. If you start messing with the inner workings of ColdFusion, upgrading CF could become a nightmare, because if Adobe decides to more or remove that dir or deal with their tags in a different way any custom tags in there will be lost or become redundant
3. All you are saving yourself by putting tags in there is typing an underscore when you call them. EG: <cfmytag> rather than <cf_mytag>

so while it is interesting, I can see no real reason for using it! :-)
# Posted By David | 5/26/07 8:34 AM