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

How to include a template from a different directory

Guest
Apr 07, 2009 Apr 07, 2009

Hi,

I have a page navigation menu that I placed in a template file.  All the browsing files would then call this template file using cfinclude. 

I now want to call this file from a different directory.  However, this causes all the url and image links to be wrong because the template file uses relative path off of root directory.

I have looked at using cfmodule, but it seems that I would have the same issues unless I make the paths absolute, which I am trying to avoid.

I also thought of prepending to every link in the template file with a directory prefix variable which I passes from the calling files.

Is there an easy and better way to solve this?

Thanks!

Min

TOPICS
Getting started
944
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

correct answers 1 Correct answer

Contributor , Apr 10, 2009 Apr 10, 2009

Simple. Use root-relative links, not relative links, in the included file.

Translate
Explorer ,
Apr 07, 2009 Apr 07, 2009

To dynamically get the absolute path from a relative path take a look at expandPath()

http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_e-g_05.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
Contributor ,
Apr 10, 2009 Apr 10, 2009

Simple. Use root-relative links, not relative links, in the included file.

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
Guest
Apr 10, 2009 Apr 10, 2009
LATEST

Hi David,

I didn't know what a root relative links was, so I looked the term up.  That is exactly what I need.  Thank you very much!

Min

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