Relative Paths for Include and Module Config Files

For the sake of it being a Monday, I thought I would post a short entry about the new relative path support for include and module configuration files in Mach-II 1.5 (available in RC1).  Yes, you heard it right - relative paths.  We added this support to make integration with third-party modules (such as MachBlog) easier.

Everybody knows the '../' (move up a directory) and ./' (same directory) syntax from HTML and *nix.  Our relative path notation for Mach-II uses the same syntax. I want to stress that all relative paths are relative from the configuration file that defines the path to the other configuration file - not relative to your webroot. For example, if you have a config file named mach-ii.xml in a directory named /appRoot/config/ and you want to include another config file that is located in the same directory as your mach-ii.xml file, it would look like this:

<include file="./other-mach-ii.xml"/>

However, you cannot just use "other-mach-ii.xml" as the path since ColdFusion's expandPath will try to expand from the webroot.  You must start a relative path with the './' or '../' syntax - which indicates to Mach-II that you are using a relativat path.

Keeping in the same style, if you have your mach-ii.xml file in the /appRoot/config/ and you want to define a module that lives in /appRoot/modules/machblog/config/mach-ii.xml, it would look like this:

<module name="blog" file="../modules/machblog/config/mach-ii.xml"/>

The example above uses the '../' syntax to move up a directory (from the /appRoot/config/), into the /appRoot directory and then in the directory path specified.  Simple!

0 Comments  |  0 Trackbacks  |  Mach-II 1.5  |  Send
Posted 8/20/07 @ 8:03 AM by Peter J. Farrell