Monday, January 31, 2005

ColdFusion Mappings revisited.

I constantly get mappings in cf screwed up when I'm building a new site from scratch. I've been doing it for years, but it just seems to be one of those things that makes you feel like an idiot.

Here are a few points to help (me) remember what's going on with these things and how to set them up right the first time.
  1. They are NOT like web server mappings. They really can only be used inside the cfmodule or cfinclude tags. You can't create a mapping and expect to use it throughout the site. It definitely will not work on pages that are not run through the cf engine.
  2. In my normal setup, their is generally one mapping per application that points to the Application root, not the server root. This helps keep the code somewhat portable and lets Dreamweaver keep up with your locations.
  3. Setting up your site in Dreamweaver - the local root folder should also point all the way down to the root of the application, not necesarily the web root.
  4. VSS should mimic this layout. If you have your application root set to c:\inetpub\wwwroot\intranet\application1, VSS should be set up with a project like this: $/intranet/application1.
  5. One aspect that I find VERY confusing is that using the "/" in your cfincludes calls up your mapping, while using "/" in regular html, like an image source, calls up the web root.
I tend to prefer this method to keep things like images in included files straight for several reasons. If your paths are set up like this, Dreamweaver can keep things straight for the most part in it's wysiwyg views. I tend to work in split mode a lot, so this comes in handy. The images are not displayed from cfincluded content. Maybe this isn't the way it's supposed to work, but it doesn't bug me as much as the broken images that get displayed with other methods.

A lot of people like to set paths in their application.cfm files. While this works fine (and is probably more robust), I just find it ugly to look at inside my code. Plus, everything you reference that way is generally shown as broken in Dreamweaver.

I think if dreamweaver had a way to supply a design time value to it's variables, that would allow the application.cfm method to feel more natural, but I haven't found a way to do that.

Note to self: update this posting if you find a better way to manage these mappings. I'm pretty sure Blackstone worked the same way.

1 comment:

  1. Thanks mike, your blog prevents me from having the same problem!

    ReplyDelete