Link to home
Start Free TrialLog in
Avatar of hefterr
hefterrFlag for United States of America

asked on

Acession Common Components in ColdFusion

Hi,
My site is expanding and I am now creating directories from the root to segregate different products.

I have CFINLUDE header and footers that refer to images  (in an Image directory from the root) and root programs if the user is not loged in).

I am having an issue using these CFINCLUDE headers and footers in new directories as the CFINCLUDES templates have HTML that refer to src="image/myimage.jpg" (for example).  

These work fine in www.mydomain.com/myprogram.cfm.  But they don't resolve as I'd like in www.mydomain.com/product1/myprogram.cfm as the relative reference doesn't resolve.

Do I have to use absolute references?  This makes test versus production tricky?

Please advise.

Thanks in advance,
hefterr  
Avatar of azadisaryev
azadisaryev
Flag of Hong Kong image

you can use paths relative to website root (start path with /):

src="/images/myimage.jpg"

Azadi
Avatar of hefterr

ASKER

Hi azadisaryev,
Thanks for help.  But It didn't seem to work?  I took a root reference :

<td align="right" class="homelinks"><img src="images/CP_SecureLinks.jpg" alt="Home - Navigation" width="197" height="16" border="0" usemap="#Map2" /></td>

and changed it to :
<td align="right" class="homelinks"><img src="/images/CP_SecureLinks.jpg" alt="Home - Navigation" width="197" height="16" border="0" usemap="#Map2" /></td>

But the image was not found (testing locally)?  Not sure how to debug this either (what path is the browser looking for)?

Please advise.
hefterr
Avatar of _agx_
> Not sure how to debug this

You can use the ExpandPath() function to see the physical image path the server is looking for

<cfoutput>
    Debug  #ExpandPath("/images/CP_SecureLinks.jpg")#
</cfoutput>

It all depends on _your_ site root, but on one of my local pc's,  my web site root "/" is:
      c:\ColdFusion8\wwwroot

So _my_ server would be looking for this image here:
     c:\ColdFusion8\wwwroot\images\CP_SecureLinks.jpg

Avatar of hefterr

ASKER

Hi aqx,
I doing something wrong as it works in production but not locally:

Prod : Debug C:\ColdFusion8\wwwroot\centrispoint\images\CP_SecureLinks.jpg    <==OK

test  with Slash: Debug C:\ColdFusion8\wwwroot\images\CP_SecureLinks.jpg <==== WRONG PATH

test without slash : Debug C:\ColdFusion8\wwwroot\centrispoint\images\CP_SecureLinks.jpg <==GOOD

I am using Dreamweaver to define my site locally when I test as :C:\ColdFusion8\wwwroot\centrispoint and I have physically defined :
c:\ColdFusion8\wwwroot\centrispoint as my directory site both on test and production.

I'm not sure what's going on locally.

Heeellllp!
hefterr
Avatar of hefterr

ASKER

Another piece of information,
Locally I ran the template : http://localhost:8500/centrispoint/test_root.cfm   -  to test both cases.  But when I add the slash in front of the image reference, the debug gives me:

Debug C:\ColdFusion8\wwwroot\images\CP_SecureLinks.jpg  ???

I'm not sure what is going on.  I am using the CF application server locally and IIS on our server.

Thanks in advance,
hefterr
Avatar of hefterr

ASKER

Sorry, one more piece of info.  You can look at http://www.centrispoint.com/test_root.cfm  on my server which is your test code.

hefterr

Avatar of hefterr

ASKER

OK - I get it now.  I just don't know what to do about it to be insynch locally and on our server with the same code.

The CF application server on has 1 root : c:\ColdFusion8\wwwroot. When I test, I always add the subfolder : http://localhost:8500/centrispoint/

But on our server, I define the root as c:\ColdFusion8\wwwroot\centrispoint.

So my code with the slash will work fine on the server but not locally as the "root" is technically different.

I have a headache!
hefterr
Right.  But if you change the root of your local server to match, you'll get the same results.  

http://www.adobe.com/support/coldfusion/adv_development/config_builtin_webserver/config_builtin_webserver04.html
>> But if you change the root of your local server to match, you'll get the same results.

yes, but that would break any other 'sites' you might have under built-in server's webroot.

Azadi
> yes, but that would break any other 'sites' you might have under built-in server's webroot.

True, but I'm not sure what the alternatives are when using the built in server rather than IIS, Apache, etc..
i am testing an alternative that does not involve switching web servers right now :)

Azadi
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> i am testing an alternative

   Cool. Let us know, because I could use something like that on one of my machines :)
Avatar of hefterr

ASKER

You are both correct.  I'd have to flip/flop my root locally to test different site/applications.

The other solution, is to change the root on the server (IIS) to C:\ColdFusion8\wwwroot and have a stub program for each site CFLOCATION to the appropriate application directory.

Not sure if that's a good idea security wise (or is that how is supposed to be done?).  I have 3 site/applications on the same server with separate directories for each under  C:\ColdFusion8\wwwroot \sitename.

What does everyone else do?

Thanks again,
hefterr
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hefterr

ASKER

Guys,
Let me know if you think of anything else.  I like aqx's idea of using the application.cfc to control the difference between test and production for shared components at different levels.

Still curious what experienced CF web developers do with multiple sites on their local PCs?

Thanks again to both for your expertise!!!
> voila! the image is displayed in pages in 'root' and in sub-folders now.

But it seems like that would require a different mapping on PROD for every site?  I'd rather change dev, than prod.
Avatar of hefterr

ASKER

azadisaryev,
I'm a bit new here so I don't know what you mean by :
>add a new virtual mapping:

<virtual-mapping>
    <resource-path>/centrispoint_images/*</resource-path>
    <system-path>C:/ColdFusion8/wwwroot/centrispoint/images</system-path>
</virtual-mapping>

FYI.  I work at home and my PC is running MS VISTA Home Premium.

hefterr
>> But it seems like that would require a different mapping on PROD for every site?  I'd rather change dev, than prod.

yes, it would require a virtual dir set up on the webserver on prod server (i.e. an IIS virtual dir). no changes to cf server are required on prod server.

but afaik, this is the only way to go about it if your local dev is on built-in cf webserver (JWS).

>> Still curious what experienced CF web developers do with multiple sites on their local PCs?

i am pretty sure 'experienced CF web developers' run a proper web server (like Apache) in their dev environment. at least i do :)

Azadi
>> I'm a bit new here so I don't know what you mean by :

read the article _agx_ posted a link to:
http://www.adobe.com/support/coldfusion/adv_development/config_builtin_webserver/config_builtin_webserver04.html

or this one:
http://livedocs.adobe.com/coldfusion/8/htmldocs/webservmgmt_3.html#102393

you need to add the virtual mapping in {cf_root}/wwwroot/WEB-INF/jrun-web.xml file.

Azadi
> yes, it would require a virtual dir set up on the webserver on prod server (i.e. an IIS virtual dir)

That's what I mean. When it comes to changes, I'd prefer to modify dev to make it match prod, rather than touching prod in any way.  (Though I don't like the variable idea much better... I have done it though).  Besides, as you say - the best solution is to use a real web server anyway ;-)
Avatar of hefterr

ASKER

azadisaryev,
Still not sure what you mean by :
>add a new virtual mapping:
<virtual-mapping>
    <resource-path>/centrispoint_images/*</resource-path>
    <system-path>C:/ColdFusion8/wwwroot/centrispoint/images</system-path>
</virtual-mapping>

Remeber, the problem I have is locally, as the server side is fine.

hefterr
If you don't want to make any changes to the prod server, I believe you only have two choices:

1) Use a variable in your application.cfc  - OR
2) Change the web root of your local server to match the one on prod.  

To change the web root for the built in server the full instructions are here:
http://www.adobe.com/support/coldfusion/adv_development/config_builtin_webserver/config_builtin_webserver04.html

Summary:  
- Find the jrun-web.xml file.  Make a backup copy.  
- Change the root to match the one on prod ie C:/ColdFusion8/wwwroot/centrispoint.
- Save the file and restart CF

<virtual-mapping>
    <resource-path>/*</resource-path>
    <system-path>C:/ColdFusion8/wwwroot/centrispoint/</system-path>
</virtual-mapping>




just remember that if you change your built-in cf server's web root as _agx_ suggest, any other sites* you have on your local server will stop working (unless you move them all into C:/ColdFusion8/wwwroot/centrispoint/ folder).

* - by 'sites' i mean if you have several websites each in separate subfolder on your local server in C:/ColdFusion8/wwwroot.

Azadi
Avatar of hefterr

ASKER

OK Thanks guys.

I think I'll initially go the application.cfc route as I'd have to flip flop the local root when developing/testing the other application/sites.

Perhaps I should ultimately install IIS locally (and upgrade to Window 7) to be in synch with the Windows 2003/IIS server.

Thanks again for your time an effort on this question (it was an interesting one :)!

hefterr
> Perhaps I should ultimately install IIS locally

Either that or Apache, etc... The built in web server is very limited.  So to do what you need ... you need a "proper" web server as Azadi says :)