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

CFinclude and mappings? Images not displaying on the calling page

Participant ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

I can't seem to get this. I have a cfinclude on a page. The original template has an image in it <a href="/image/pic.gif">, which does not show on the calling page. I understand I have to create a mapping on the CF server.

It's requesting a logical path and a directory path. I don't know what to put here; I tried every variation and the images still don't show on the calling page.
TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

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

Participant , Jun 14, 2007 Jun 14, 2007
Thanks anyway. I figured out another solution.

For other folks, I created an application variable with the full virtual path including domain name in Application.cfm.
<CFSET httpdir = " http://www.domain.com/">

I then use the variable in the img src that's in the include file:
<img src="<cfoutput>#httpdir#</cfoutput>images/pic.gif" />

Now the cfinclude can go in any folder on the server and be applied to any page on the server and the image url won't be broken.

Votes

Translate

Translate
Guest
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

Take a look at the HTML source the ColdFusion page generates. Is the path to the image correct? If not, it should be evident what needs to be fixed.

Votes

Translate

Translate

Report

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
Participant ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

quote:

Originally posted by: jdeline
Take a look at the HTML source the ColdFusion page generates. Is the path to the image correct? If not, it should be evident what needs to be fixed.


HTML source simply shows <a href="/image/pic.gif">

I'm trying to use a mapping, because if I use a relative path to the image then the image does not get displayed when the CFinclude is used on page that's in a different directory because the image path becomes broken. I would then have to keep changing the image path in the CFInclude file itself, which defeats the purpose.


Votes

Translate

Translate

Report

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 ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

i think what you need is a webserver virtual directory, not a cf
mapping. cf mapping is only used in cf tags...
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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 ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

correction/addition:

you can use you cf mapping if you format your link like this:

<a href="<cfoutput>#expandpath('/yourcfmapping')#</cfoutput>/yourfilename">

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Participant ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

I'll try explaining better. I have:

1. Caller Page which is an index.cfm page in the root folder of the virtual directory:
Index.cfm
<cfinclude template="cfincludes/footer.cfm">

2. In the actual CFInclude page (footer.cfm) file stored in a "cfincludes" folder I have:

cfincludes/footer.cfm

<img src="../images/pic.gif" width="43" height="27" />
This is a relative path to the image from the page.

The image is not shown on the caller page.

I'm assuming because the image path is a relative path from the cfincludes folder up to the images folder, but when the code is executed in real time and placed in the caller Index.cfm file the path is broken.

So what can you possibly do to get that working

Votes

Translate

Translate

Report

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
Participant ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

Thanks anyway. I figured out another solution.

For other folks, I created an application variable with the full virtual path including domain name in Application.cfm.
<CFSET httpdir = " http://www.domain.com/">

I then use the variable in the img src that's in the include file:
<img src="<cfoutput>#httpdir#</cfoutput>images/pic.gif" />

Now the cfinclude can go in any folder on the server and be applied to any page on the server and the image url won't be broken.

Votes

Translate

Translate

Report

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 ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

yep that's a decent solution, if not a perfect one.

did you try my suggestion (<a
href="<cfoutput>#expandpath('/yourcfmappeddirectoryhere')#</cfoutput>/yourimagefilenamehere">)?
didn't it work for you? it seemed to work fine in my tests....

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Participant ,
Jun 15, 2007 Jun 15, 2007

Copy link to clipboard

Copied

quote:

Originally posted by: Newsgroup User
did you try my suggestion (<a
href="<cfoutput>#expandpath('/yourcfmappeddirectoryhere')#</cfoutput>/yourimagefilenamehere">)?
didn't it work for you? it seemed to work fine in my tests....



Azadi, I didn't try it because I didn't know how to do mapping in Coldfusion Admin actually.

Votes

Translate

Translate

Report

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 ,
Jun 15, 2007 Jun 15, 2007

Copy link to clipboard

Copied

LATEST
oops... just re-read your original post and now i understand...

well, if you have access to cf Admin, and it looks like you do, all you
have to do to create a mapping is:
Logical Path: whatever name you want ot give your cf mapped directory
(presumably images or pics in your case)
Directory Path: actual directory on the server which will be now
accessible through the mapping. It has to be a directory/folder which
CF can access. I.e. C:\Inetpub\wwwroot\mypicsfolder or D:\My Pics\web
pics or whatever the name of the folder you want to map

that's all

now your mapped folder will be accessible to cf tags & functions. just
keep in mind that to make sure CF looks in the mapped folders, include
the / before the folder name: /images or /mypics. also keep in mind that
it is a CF setting and is only available to CF, i.e. in a regular <a
...> link or <img ...> tag it will not point to the mapped folder - it
must be used inside cf tag (like <cfinclude
template="/mymappeddir/myfile.cfm"> will get the myfile.cfm from the
mapped directory) or function (as in the expandpath() function i used in
my previous post).

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Documentation