ColdFusion 8: Per App Dynamic Mappings and Custom Tag Paths Create Dropable Applications
ColdFusion 8One small but really cool feature of ColdFusion 8 is the ability to define mappings and custom tag paths within an Application.cfc file. It is now possible to create dynamic mappings and with that completely dropable applications. I've always liked the concept of CF mappings but not the hassle of configuring every server for my mappings. CF8 removes the later concern and now it can fully use the power of CF mappings.
Lets take a look inside an Application.cfc:
Thats it! Drop this cfc on any folder on any server and the mapping "mymap" will work. Sure makes referencing cfc's a whole lot easier.
Same thing for custom tags except this time I designated a tags folder for my custom tags. You can specify multiple custom tag paths by using a list of paths that get checked in order. Likewise you can add as many mappings as you like.
How does getDirectoryFromPath and getCurrentTemplatePath functions work? Neither are new to 8, the getCurrentTemplatePath function will always return the full system path to the current file (not the requested) whether its a cfm or cfc. GetDirectoryFromPath simply strips the file from the path and gives us exactly what we want in this case.
Why not place these settings in the onApplicationStart function?
The way I look at it the "this" scope is how you define the application to the ColdFusion engine while application variables and anything that happens in the onApplicationStart function are something programmers use.





Loading....