Skip to main content
Inspiring
September 23, 2008
Question

How can you include a template outside of root directory?

  • September 23, 2008
  • 3 replies
  • 614 views
Is there a way to include a template file from outside of the root directory?

Example:

<cfinclude template=" http://www.whatever.com/templates/whatever.cfm">

Can this be done? I keep on getting this error when I try this:

The filename, directory name, or volume label syntax is incorrect
This topic has been closed for replies.

3 replies

Participating Frequently
September 24, 2008
Try this.
Inspiring
September 23, 2008
<cfinclude> doesn't take a URL, it takes a path.

This is all covered in the docs (which should be your first point of call
when wanting to know how something works):
http://livedocs.adobe.com/coldfusion/8/Tags_i_05.html

--
Adam
Inspiring
September 23, 2008
xstortionist wrote:
> Is there a way to include a template file from outside of the root directory?
>

Yes, assuming you mean you are including a file available to the server.
You can create a ColdFusion Mapping to any directory you like and then
use that mapping to find the desired resource.


I.E.
ColdFusion Administrator:
Active ColdFusion Mappings
/my_famous_mapping E:\aDirectory\aSubDirectory\

Then your code would be...
<cfinclude template="/my_famous_mapping/something/aFile.cfm">

This would then include the template found at
E:\aDirectory\aSubDirectory\something\aFile.cfm.

If you are trying to include a file from another server using a URL,
then you will need to be looking at the <cfhttp...> tag.

<cfhttp url=" http://www.whatever.com/templates/whatever.cfm"...>