Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

creating dynamic paths/mappings in Application.cfc?

New Here ,
Aug 28, 2009 Aug 28, 2009

Hey Guys!

I want to create a dynamic path or mapping that points back to my sites root.

So that way no matter if I have this:

<cfinclude template="../../includes/header.cfm">

Or this:

<cfinclude template="../includes/header.cfm">

It would be something like this:

<cfinclude template="#application.siteroot#header.cfm">

I know there are functions out there that help grab directory names and such but putting them all together is the confusing part.

Thanks for any help on this.

Chris

1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 28, 2009 Aug 28, 2009

You could create a mapping in so that in ColdFusion the path "/site_includes" translates to specific directory on the file system such as "C:\sites\site1\include_files".  The mapped directory does not have to be within your web site directory structure.  You may wish to put include files or components outside of you web directory structure so they can only  be accessed through your CF code and not by browsing to a URL such as "http://www.example.com/includes/header.cfm".  See the "Mappings page" below for configuring mappings the CF administrator.  You can also add mappings in your Application.cfc.  See "Specifying settings per application" below.

"Mappings page"
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=basiconfig_10.html#1162230

"Specifying settings per application"
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=appFramework_04.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2009 Aug 31, 2009

Hello and thanks for your reply!

Thank you for the information you provided but what I am looking for is how I can accomplish this task via code?

For instance:

It was my fault but I neglected to mention that I am calling this include from several layers deep in folder directories.

Path to includes = /includes/header.cfm

Current path to the createUser.cfm page = /pages/users/createUser.cfm

these includes all have mappings to other directorys for their css and images so I really need a way to set up dynamic paths/mappings preferibly in code...if not then I can try to go the ColdFusion Administrator route.

One last question. I have been out of the ColdFusion game for about 5 years, was your last suggestion the preferred method for doing what I've requested nowadays?

Thanks and take care!

Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 01, 2009 Sep 01, 2009
LATEST

You might try some code similar to the sample under "Set the custom tag paths per application" section at http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=appFramework_04.html to set mappings programmatically.

Bear in mind that these mapping only apply when used in CF code such as the CFINCLUDE tag. It does not apply to paths in the end user's browser such as an image tag.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources