Hey Taco,

I didn't understand your issue before (my bad) and now I understand
your issue and having a quick test, I can see why your went with your
solution.

The expandPath("/") will happily return the webroot's location, which
isn't always the application root.

Every test I attempted ended up hardcoding at least one value, which,
to keep apps portable, would not be ideal.

doing a cfinclude in a CFC always feels wrong, but in this case seems
to be required.


On Jun 9, 5:08 pm, "Andrew Scott" <[EMAIL PROTECTED]> wrote:
> Taco...
>
> http://www.andyscott.id.au/index.cfm/2007/6/8/Extending-Application-C...
>
> On 6/6/07, Taco Fleur <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > David, don't worry, it works for me.
>
> > On 6/6/07, David Harris <[EMAIL PROTECTED]> wrote:
>
> > > So from what you have there, the line of code in the included file:
> > > request.applicationRoot =
> > > getDirectoryFromPath( getCurrentTemplatePath() );
>
> > > is the one to get you the root of the application?
>
> > > I would expect:
> > > expandPath("/")
>
> > > to give you that too, no matter where in the application you run it,
> > > from a .cfm or a .cfc, 1 folder deep or 10 folders deep
>
> > > I have only tested this on my dev machine, and it returns "C:\Inetpub
> > > \wwwroot\", which is my web root, no matter where I called it from
>
> > > What did you get when you tried that snippet in your testing?
>
> > > On Jun 6, 6:53 pm, "Taco Fleur" <[EMAIL PROTECTED]> wrote:
> > > > 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/)+(developme-nt%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.cfcthat
> > > > > > > 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- Hide quoted text -
>
> > > > - Show quoted text -
>
> > --
> > *** { . } { . } ****
> >http://www.clickfind.com.au
> > The new Australian search engine for businesses, products and services
>
> --
>
> Senior Coldfusion Developer
> Aegeon Pty. Ltd.www.aegeon.com.au
> Phone: +613  8676 4223
> Mobile: 0404 998 273


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to