Skip to main content
WolfShade
Legend
April 25, 2014
Answered

One directory above GetDirectoryFromPath(GetTemplatePath())

  • April 25, 2014
  • 2 replies
  • 899 views

Hello, everyone.

I'm sure this is going to be super-easy for someone to answer.  I think I've seen the correct answer, before, and I am just not recalling it.

I've tried Googling it; finding a lot of stuff, but not the answer to my question.

In application.cfc, for this.mapping[], how do I indicate a directory one level "up" from current using GetDirectoryFromPath(GetTemplatePath())?

I've got a project in a main folder that contains an admin folder, each with their own application.cfc.  But admin is using components in the main folder, not it's own.

Components are in C:\ColdFusion10\cfusion\wwwroot\project\components\ and the admin is in C:\ColdFusion10\cfusion\wwwroot\project\admin\

V/r,

^_^

    This topic has been closed for replies.
    Correct answer tribule

    Just use:

    #ExpandPath( "../" )#

    That will get you one level above where you are now Keep adding "../" to go up a level.

    2 replies

    tribuleCorrect answer
    Legend
    April 25, 2014

    Just use:

    #ExpandPath( "../" )#

    That will get you one level above where you are now Keep adding "../" to go up a level.

    BKBK
    Community Expert
    Community Expert
    April 26, 2014

    To expand on what Tribule says, for an Application.cfc in the admin directory, the absolute path of the project directory is expandPath("../project") and the absolute path of the components directory is expandPath("../project/components").

    Addendum

    Oh, by the way, getTemplatePath() was deprecated long ago.

    Message was edited by: BKBK

    WolfShade
    WolfShadeAuthor
    Legend
    April 28, 2014

    Thank you for your replies, @tribule and @BKBK.

    !!!  Can't believe that I didn't think of "../"; like I said, I'm sure it's a simple solution that I'm just not recalling.

    The project has an Application.cfc, but the admin folder in that project also has its own Application.cfc, and I don't want to "include" the root Application.cfc in the admin one.  So, the "../" per directory level should work perfectly from within the admin Application.cfc.  I'll give that a shot and report back.

    BTW, did not know that getTemplatePath() had been deprecated.  Thanks for the heads-up.

    V/r,

    ^_^

    UPDATE:  Success.  That nailed it.  Works perfectly.  Thank you, again!

    Carl Von Stetten
    Legend
    April 25, 2014

    Can you maybe show the folder structure so it's clear where you are and where the mapping should point?


    Thanks,

    -Carl V.