Solved

Coldfusion cfinvoke with relative path

Posted on 2010-11-15
3
1,264 Views
Last Modified: 2012-05-10
Hello,

I am using coldfusion to invoke components and I have this question:

Is there a way to invoke a component using a relative path?

My problem is this:

In my development environment, I am using one CF install to work on multiple sites, meaning that my site root folders look like this :  http://localhost:8500/site1, http://localhost:8500/site2, etc...

On my remote host, however, I do not use this "/site1 or /site2" directory structure, but rather just the site root.  So instead of 'www.mysite.com/site1', my URL is 'www.mysite.com'  

This poses a problem when my component calls during development HAVE to go through the 'site1' directory (ex. <cfinvoke component="site1.main.components.myComponent"), and my component calls during deployment do NOT (ex. <cfinvoke component="main.components.myComponent").

I do not want to have to change ALL my <cfinvoke> tags EVERY time I put files, then change them back EVERY time I test them locally.

Does anyone have a solution to this problem?
0
Comment
Question by:chaseivey
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 250 total points
ID: 34137105
Store your cfc root in an application variable on start up.
       <cfset application.cfcroot = "site1.main.components">

Then use it when invoking components
       <cfinvoke component="#application.cfcroot#.myComponent" ...>

Then you only have to change one variable when switching to the remote site.  There are better options for Apache, IIS, etc... but those won't work with the builtin web server.
0
 

Author Closing Comment

by:chaseivey
ID: 34167229
I apologize for the delayed answer. For some reason, I thought I already answered.  :(. Thank you for the help
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34167279
You're welcome (Btw: I've seen questions open for 10 months or more. So a couple days is pretty good ;-)
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question