开发者

Coldfusion mapping error

Note:开发者_C百科 If you wish to use an absolute template path (for example, template="/mypath/index.cfm") with CFINCLUDE, you must create a mapping for the path using the ColdFusion Administrator.

I went to the administration page but not sure what to put in here. I'm pretty new to coldfusion. anyone got any ideas why this would be happening.


CFINCLUDE uses relative paths in relation to the file where the cfinclude is, so if want to include a file in another directory, 1. it has to be inside your wwwroot (or the root directory, or subdirectories) of your site, 2. you can go to other directories by doing ... hope this helps a little bit. If you want to include a file that is outside of your wwwroot, then you'll need to map that directory in Coldfusion Administrator using the same syntax above when you do include it.


To add a mapping, open your coldfusion administrator.

Server Settings > Mappings

There are 2 paths. Logical and Directory.

Logical can be anything you want, and directory is where it maps to. eg. you might have a folder below your web root which stores email templates mapped as:

logical path: /emails
directory path: /var/www/mycfapp/content/includes/emails

You can <cfinclude template="/emails/forgotPass"> from any cf template and the mapping would get picked up.

You can use the mappings for new object creation too. Lets pretend forgotPass is a cfc.

fp = new emails.forgotPass();

// if you have funky characters in there, eg dash, just quote it.
fp = new "emails.forgot-pass"();

Mappings also work when extending cfcs. With one small exception. No leading slash.

component extends="emails/forgotPass" {
    // ...
}

Im pretty sure mappings are detected first, so if you have a folder with the same name it might not get picked up.

In cf9 you can also specify your mappings in your Application.cfc, instead of coldfusion administrator, which affects all applications on your server. eg.

this.mappings["/emails"] = "/var/www/mycfapp/content/includes/emails";

You'll need to tick the Enable Per App Settings option on the cfadmin Settings page.

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0b63c-7fd5.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜