Skip to main content
WolfShade
Legend
Apr 25, 2014 3:49 PM UTC
Answered

One directory above GetDirectoryFromPath(GetTemplatePath())

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 is closed to new replies. Start a new post to keep the conversation going.
    tribuleCorrect answer
    Legend
    Apr 25, 2014 9:35 PM UTC

    Just use:

    #ExpandPath( "../" )#

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

    5 replies

    tribuleCorrect answer
    Legend
    Apr 25, 2014 9:35 PM UTC

    Just use:

    #ExpandPath( "../" )#

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

    Translate
    BKBK
    Community Expert
    Community Expert
    Apr 26, 2014 9:59 PM UTC

    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

    Translate
    WolfShade
    WolfShadeAuthor
    Legend
    Apr 28, 2014 12:53 PM UTC

    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!

    Translate
    Carl Von Stetten
    Legend
    Apr 25, 2014 8:41 PM UTC

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


    Thanks,

    -Carl V.

    Translate