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

Question on include

New Here ,
Sep 03, 2008 Sep 03, 2008

Good day! I am a beginner developer CF. I have created a site, 10 points in the navigation menu (About, News, Articles, contacts, etc.). I have created a template, then cut a cap, levle menu, to include the basement and first save Includes. Then I for each page (on menu items) created a folder and put into each file folder index.cfm ...
I have a question - Home page I have also kept in a folder Home (that is, there is a file index.cfm). At localhost: 8500 I have everything works, but if I index.cfm page of the Home folder moved to the root of the site, it will not connect Include and images do not appear. Is it possible to spread the files on hosting, if I file page Home index.cfm is in the folder Home, rather than the root site? Help please?
TOPICS
Getting started
691
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
LEGEND ,
Sep 03, 2008 Sep 03, 2008
There are two ways to cfinclude when the included file is in a different directory

absolute path from the webroot.
eg template = "/folder1/folder2/file.cfm"

relative path from current directory
eg template = "../folder1/folder2/file.cfm"
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 ,
Sep 03, 2008 Sep 03, 2008
Dan Bracuk, but as I do better if:
folder Home / index.cfm
folder About / index.cfm
folder News / index.cfm
folder Article / index.cfm
folder Include / header.cfm footer.cfm etc.
folder Images / pictures are here
Where should I stay home site, in my example, it is in the folder Home / index.cfm
If I commend her from the Home folder in the root site, I have ceased to display pictures and include
And where must be a pattern?
Thank you!
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
LEGEND ,
Sep 03, 2008 Sep 03, 2008
If your include and images folder are directly below the web root, an absolute path should work.
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 ,
Sep 05, 2008 Sep 05, 2008
Hi! Something does not get me. I made wrong question (sorry for poor English, I am from Moscow)
I have a problem not include, but img, which are included in the blocks include
Sample
I save a page in the root folder index.cfm site. Connect menu include the left block with pictures. All worked perfectly.
I also established a Contact folder and file it also put index.cfm (Contact / index.cfm) Tam also connected include - everything works, only img files do not appear.
For the images I created a folder images, for includs folder Include
In my case, the way pictures are like in Includ-file leftmenu.cfm
<a href="../ "> <img src="../images/AU.gif" class="flag"/> A ustralia </ a>
The path includa looks like this:

index.cfm file in the root site
<cfinclude template="includes/leftmenu.cfm">
index.cfm in the file in the folder Contact (Contact / index.cfm)
<cfinclude template="../includes/leftmenu.cfm">
As a result, in the latest file include & img worked perfectly, and in the index.cfm file at the root of the site - do not appear Img
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
LEGEND ,
Sep 05, 2008 Sep 05, 2008
I'm sorry if I am not correctly following your story, it is challenging.

But it is important to note that <cfinclude...> will have absolutely no
bearing on what path would be used in an <img...> tag. ColdFusion does
not request the image, the browser does. The browser needs to know
where the image is in relation to the URL that requests it.

An attempt at an example.

/wwwroot/includes/my_include.cfm
/wwwroot/images/an_image.jpg
/wwwroot/index.cfm
/wwwroot/subDir/index.cfm.

Any code in wwwroot/index.cfm, even code included from my_include.cfm,
would need to find the image in the subdirectory wwwroot/images.

Relative Path:
<img src="images/an_image.jpg"/>

Absolute Path:
<img src="/images/an_image.jpg"/>

Any code in wwwroot/sbDir/index.cfm, even code included from
my_include.cfm, would need to find the image up one directory in
wwwroot/images.

Relative Path:
<img src="../images/an_image.jpg"/>

Absolute Path:
<img src="/images/an_image.jpg"/>

As you can see the absolute path version is the only one that is the
same if the my_include.cfm file is going to be used in different
locations within the site.

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 ,
Sep 05, 2008 Sep 05, 2008
LATEST
Thank you, I have worked! Ie I realized I must make copies of files my_include.cfm and keep it in Wwwroot? A permitted when my_include.cfm saved in a folder Include in the root folder Site 2 times?
And you can do for another, for example, that home site (index.cfm) also kept in subfolders (My-Home/index.cfm)?
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