Created application-root.cfm with following code <cfscript> request.applicationRoot = getDirectoryFromPath( getCurrentTemplatePath() ); request.applicationRoot = reReplaceNoCase( request.applicationRoot, "( \\|/)$ <file://%7C/)$>", "" ); </cfscript>
Snippet of the application.cfc <cffunction name="onApplicationStart" returntype="boolean" output="false"> <cfinclude template="application-root.cfm"> <cfscript> variables.mode = "unknown"; result = reFindNocase( "( \\|/)+(development|testing|staging|production)(\\|/<file://%7C/)+(development%7Ctesting%7Cstaging%7Cproduction)(//%7C/>)+", request.applicationRoot, 1, true ); if ( arrayLen( result.pos ) gt 1 ) { variables.mode = mid( request.applicationRoot, result.pos[ 3 ], result.len[ 3 ] ); } </cfscript> <cfparam name="application.web.root" default="" type="string"> <cfparam name="application.root" default="/#this.application_name#" type="string"> <cfparam name="application.mode" default="#variables.mode#" type="string"> On 6/6/07, David Harris <[EMAIL PROTECTED]> wrote: > > > any chance of example code of what you did Taco? > It'll help me understand the issue :-) > > On Jun 6, 6:23 pm, "Taco Fleur" <[EMAIL PROTECTED]> wrote: > > Thank god! > > > > I've already solved the matter by creating a normal .cfm file and > include it > > in the onApplicationStart - I was just hoping for a solution that would > not > > involve any code outside the application.cfc > > > > On 6/6/07, Andrew Scott <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > > > > > Taco, > > > > > I know what you are saying now, there is an answer but I have it in > code I > > > have at home. > > > > > Andrew Scott > > > Senior Coldfusion Developer > > > Aegeon Pty. Ltd. > > >www.aegeon.com.au > > > Phone: +613 8676 4223 > > > Mobile: 0404 998 273 > > > > > *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] > *On > > > Behalf Of *Taco Fleur > > > *Sent:* Wednesday, 6 June 2007 3:52 PM > > > *To:* cfaussie@googlegroups.com > > > *Subject:* [cfaussie] Re: Get root of the application > > > > > I give up.... > > > > > On 6/6/07, *David Harris* <[EMAIL PROTECTED]> wrote: > > > > > I just created a folder struct of [root]/one/two/bob.cfm > > > and put the code: > > > <cfoutput>#getDirectoryFromPath(expandPath("/"))#</cfoutput> > > > > > in bob.cfm, and it gave me the correct web root... > > > > > I also put a onRequestStart function in my Application.cfc: > > > > > <cffunction name="onRequestStart" output="true"> > > > <p> > > > here: <cfoutput>#getDirectoryFromPath(expandPath("/"))#</cfoutput> > > > </p> > > > </cffunction> > > > > > ran "/one/two/bob.cfm"...and the correct web root was output > > > > > so from my testing > > > <cfoutput>#getDirectoryFromPath(expandPath("/"))#</cfoutput> > > > > > works every time... > > > > > On Jun 6, 5:30 pm, "Taco Fleur" <[EMAIL PROTECTED] > wrote: > > > > If you put this in the main application.cfc file and then make sure > the > > > app > > > > is not initialized, call a page within the sub directory (i.e. the > one > > > where > > > > the application.cfc is that extends the main one) then you will get > the > > > path > > > > of the sub directory and not the main root. > > > > > > I've now created a .cfm file that is included onApplicationStart and > > > sets > > > > the appropiate variable. > > > > > > On 6/6/07, David Harris < [EMAIL PROTECTED]> wrote: > > > > > > > how bout this?: > > > > > > > <cfoutput>#getDirectoryFromPath(expandPath("/"))#</cfoutput> > > > > > > > On Jun 6, 2:45 pm, "Taco Fleur" <[EMAIL PROTECTED]> wrote: > > > > > > Does that work for you if you put it in an application.cfc that > > > extends > > > > > the > > > > > > root application.cfc, and access a page in that sub directory > first, > > > > > also > > > > > > make sure the app is not initialised yet. > > > > > > > > Let me know.. > > > > > > > > On 6/6/07, Andrew Scott <[EMAIL PROTECTED]> wrote: > > > > > > > > > This not work for you, sure works for me? > > > > > > > > > getDirectoryFromPath(getCurrentTemplatePath()) > > > > > > > > > Andrew Scott > > > > > > > Senior Coldfusion Developer > > > > > > > Aegeon Pty. Ltd. > > > > > > >www.aegeon.com.au > > > > > > > Phone: +613 8676 4223 > > > > > > > Mobile: 0404 998 273 > > > > > > > > > *From:* cfaussie@googlegroups.com [mailto: > > > [EMAIL PROTECTED] > > > > > *On > > > > > > > Behalf Of *Taco Fleur > > > > > > > *Sent:* Wednesday, 6 June 2007 12:31 PM > > > > > > > *To:* cfaussie@googlegroups.com > > > > > > > *Subject:* [cfaussie] Get root of the application > > > > > > > > > Hi all, > > > > > > > > > I used be able to get the root of an application by putting > > > something > > > > > like > > > > > > > getCurrentTemplate() in the root application.cfm, even if I > > > included > > > > > the > > > > > > > root application.cfm in sub application.cfm files it would > record > > > the > > > > > > > right path, i.e. that of the root. > > > > > > > > > Now with the application.cfc I cannot get the right path > anymore, > > > > > because > > > > > > > if the application is initialised through an application.cfcin a > > > sub > > > > > > > directory, it reports the path of that sub directory. I've > also > > > tried > > > > > all > > > > > > > other functions like getBaseTemplate etc. nothing gives me the > > > right > > > > > output, > > > > > > > the path of the root application.cfc is what I am after. > > > > > > > > > Only thing I can think of is putting a cfm file in the root > that > > > > > outputs > > > > > > > the path I am after. I don't like hard coding it. > > > > > > > > > Thanks. > > > > > > > > > -- > > > > > > >http://www.clickfind.com.au > > > > > > > The new Australian search engine for businesses, products and > > > services > > > > > > > > -- > > > > > > *** { . } { . } ****http://www.clickfind.com.au > > > > > > The new Australian search engine for businesses, products and > > > services- > > > > > Hide quoted text - > > > > > > > > - Show quoted text - > > > > > > -- > > > > *** { . } { . } ****http://www.clickfind.com.au > > > > The new Australian search engine for businesses, products and > services- > > > Hide quoted text - > > > > > > - Show quoted text - > > > > >http://www.clickfind.com.au > > > The new Australian search engine for businesses, products and services > > > > -- > > *** { . } { . } ****http://www.clickfind.com.au > > The new Australian search engine for businesses, products and services- > Hide quoted text - > > > > - Show quoted text - > > > > > -- *** { . } { . } **** http://www.clickfind.com.au The new Australian search engine for businesses, products and services --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~----------~----~----~----~------~----~------~--~---