The subtle pen, the invisible editor

I am the subtle pen, the invisible editor. Few know me for my work but it touches many without their knowledge. I do not have the professional editorial eye of Judith or Dana and they rarely leave me anything to do. My eye is for the small modification to a sentence, the missing word that helps connect someone to what their reading. My eye is the eye of others and how to make what they are reading comfortable. My eye is unseen but watches all that we print.

Discredited magazine publisher at war with Adobe

A discredited and SYStematically CONniving magazine publisher has fired yet another salvo at Adobe today in their usual manner. This involves taking a blog post, re-branding it as coming from their "news desk" and altering the title to fit their vendetta. The post in question was BlueDragon Open Source - Launch Date Announced by Alan Williamson about how the New Atlanta team is working hard to get a public release ready for display at cf.Objective() 2008. Informative and straight forward. The re-branded version had the same title with a single alteration, a prefix of "ColdFusion Killer".

At no time did Alan say anything about the open source BlueDragon being a ColdFusion killer. It's not something that's been said by anyone...other than the publisher in question.

Really guys, this is getting old and stale. Just because Adobe stopped advertising with you doesn't mean you have to commit fraud to get back at them. Lame.

ColdFusion 8 Per App Settings - Mappings

According to the documentation for this feature, Per App mappings allows you to dynamically set "logical aliases for paths to directories on your server." This sounds great but the code example in the documentation is wrong and this leads to a lot of frustration.

The first problem is that the docs show how to set a mapping for an application but not how to use it. We could experiment a bit and eventually find out the exact syntax needed except for the second problem - the example code given to set the mapping is wrong.

The documentation says to use the following to set a mapping of "MyMap" pointing to the location "c:\inetpub\myStuff".

<cfset this.mappings["MyMap"]="c:\inetpub\myStuff">
If we place a file called test.cfm into the "c:\inetpub\myStuff" directory we should be able to include it using standard cfinclude syntax. The problem is, no matter how we try, we can not get this to work.
<cfinclude template="MyMap/test.cfm">
<cfinclude template="/MyMap/test.cfm">
<cfinclude template="#MyMap#/test.cfm">
<cfinclude template="/#MyMap#/test.cfm">
<cfinclude template="this.mappings.MyMap/test.cfm">
<cfinclude template="/this.mappings.MyMap/test.cfm">
<cfinclude template="#this.mappings.MyMap#/test.cfm">
<cfinclude template="/#this.mappings.MyMap#/test.cfm">
<cfinclude template="this.mappings['MyMap']/test.cfm">
<cfinclude template="/this.mappings['MyMap']/test.cfm">
<cfinclude template="#this.mappings['MyMap']#/test.cfm">
<cfinclude template="/#this.mappings['MyMap']#/test.cfm">
Every one of the attempts above results in an error. This leads to a ton of frustration and a search across the net for working examples. The problem with that is that there are no clear cut examples showing how to make this work.

The solution lay partially in a blog post by Sean Corfield (Scazu Powered By ColdFusion 8) where he shows how he created a number of dynamic mappings for his application. In his example code he added a forward slash before the name of the mapping, something not mentioned in the ColdFusion documentation. This is the key. This single character makes the difference between frustrating failure and a successful feature. Adding the slash we get an setting of:

<cfset this.mappings["/MyMap"]="c:\inetpub\myStuff">
and a usage of
<cfinclude template="/MyMap/test.cfm">
Frustration solved.

So to recap, ColdFusion 8 allows an application to have dynamic mappings. These are defined in the application.cfc using a syntax of this.mappings["/MyMap"] where MyMap is the mapping name. Once set, the dynamic mapping is used like any other mapping with a syntax of "/MyMap/...".

One fast note - We can use any name we want for a dynamic mapping even if the name is in use by a mapping set in the administrator. The only restriction is that if we try to set a dynamic mapping with "/", an error will be thrown. We always have to have some text after the forward slash.

BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner
House of Fusion | ColdFusion Jobs @ House of Fusion | Fusion Authority