Skip to main content
Known Participant
August 30, 2010
Answered

CF Mappings

  • August 30, 2010
  • 2 replies
  • 1155 views

It seems in a shared enviroment that the cf mappings would be an pain.  If I understand this correctly to have /customer/path/file.html included you would need to create a mapping for /customer/path/ but then if another site uses /customer/path/ without specifing a mapping in the Application.cfc they would end up using that mapping and getting an error because they can't use my files in my folder because of sand box security. Am I correct?

    This topic has been closed for replies.
    Correct answer Adam Cameron.

    expandPath() will output a full file system path, eg: C:\inetpub\wwwroot\path\to\file.cfm

    However a <cfinclude> tag doesn't take a path like that, it takes one of three things:

    * a path relative to the current template, eg:

    ** "file.cfm" if the file with the <cfinclude> in it is in C:\inetpub\wwwroot\path\to

    ** "../some/other/path/file.cfm (similar to above, just moving up a dir first

    * an absolute path relative to the CF root, eg: /path/to/file.cfm

    * a absolute path based on a mapping, eg: /mapping/some/other/path/to/file.cfm, where there is a mapping /mapping pointing to an apporpriate location

    I think perhaps also an absolute path from the WEBROOT (ie: if the webroot and the CF root are not the same dir), similar to the CF root example above.  I'm not 100% certain of this though.

    As for your initial question, I saw it, but I never use sandboxed environments - I just use separate servers - so I did not know the answer.  However irrespective of sandbox settings, if you have mappings that are not server-wide, I'd make them application-specific in Application.cfc.

    HTH.

    --

    Adam

    2 replies

    Sin0cideAuthor
    Known Participant
    September 2, 2010

    It seems that I am speaking a  different language because nobody responds to my threads. O well I was  able to find out what I was looking for.

    My code was

    <cfinclude template="#ExpandPath('.')#/design/001/header.html" />

    AND

    <cfinclude template="#ExpandPath('/design/001/header.html')#" />

    I even tried doing a cfset to myPath and dumped the var it said it was right but it still showed the not found error from the cfinclude.

    But  it did not like the way I formated it with ExpandPath. It kept telling  me the template could not be found and I needed a mapping for anything  outside fo the directory. So I was able to use the follow to get it to  work. Seems very simple but it was a headache I have no idea why the  others did not work. Any Ideas?

    <cfinclude  template="./design/001/header.html" /> (Mine actually looks like this  <cfinclude template=".#getDesign.path#/header.html" /> because I  have the value in a database and I did a query called getDesign)

    Adam Cameron.Correct answer
    Inspiring
    September 2, 2010

    expandPath() will output a full file system path, eg: C:\inetpub\wwwroot\path\to\file.cfm

    However a <cfinclude> tag doesn't take a path like that, it takes one of three things:

    * a path relative to the current template, eg:

    ** "file.cfm" if the file with the <cfinclude> in it is in C:\inetpub\wwwroot\path\to

    ** "../some/other/path/file.cfm (similar to above, just moving up a dir first

    * an absolute path relative to the CF root, eg: /path/to/file.cfm

    * a absolute path based on a mapping, eg: /mapping/some/other/path/to/file.cfm, where there is a mapping /mapping pointing to an apporpriate location

    I think perhaps also an absolute path from the WEBROOT (ie: if the webroot and the CF root are not the same dir), similar to the CF root example above.  I'm not 100% certain of this though.

    As for your initial question, I saw it, but I never use sandboxed environments - I just use separate servers - so I did not know the answer.  However irrespective of sandbox settings, if you have mappings that are not server-wide, I'd make them application-specific in Application.cfc.

    HTH.

    --

    Adam

    Sin0cideAuthor
    Known Participant
    September 2, 2010

    That makes sense. I am a Server Operations and Support tech for a company that does Coldfusion hosting. I am one of the newer guys to the team and I recently took on CF guy roll for my department. There are some Server Admin's on the server team that know a lot about admin duties but when it comes to coding most of them a lost. I am the only real coding enthiest and get made fun of by the php/perl guys and the asp.net guys. I deal with those languages on a debug/troubleshoot basis only. I have coded in php/perl before though. Thanks for the feedback I think most of my questions are more complicated then most because if I was able to figure it out with the live docs I would not be asking ;-)

    Sin0cideAuthor
    Known Participant
    September 2, 2010

    ...