Skip to main content
September 10, 2007
Question

application.cfm in root and subdirectory, help.

  • September 10, 2007
  • 2 replies
  • 848 views
I cannot figure this out. I understand that an application will use the application.cfm file in it's current directory first and not search further. However, my page in a subdirectory seems to not see the application.cfm in it's own directory and instead uses the root application.cfm. Can anyone explain? And I have tried capitalizing the "A", etc. but I am not using Linux so I do not think it matters anyway. (CF MX)
    This topic has been closed for replies.

    2 replies

    Participating Frequently
    September 10, 2007
    Hard to tell exactly, but in the subdirectory, is the ONLY line the <cfset application.dsn_test = "DiningHall">?

    If so, the subdirectory application.cfm would execute and the parent would not, which would cause the undefined error since from what I can tell, you haven't used the <cfapplication> tag in the subdirectory.

    What you can do is use a cfinclude in the subdirectory application.cfm.

    <cfinclude template="../application.cfm">
    <cfset application.dsn_test = "DiningHall">

    However.... That's a big no no if you're using this to actually change application scope parameters, since someone visiting the subdirectory would reset the DSN for someone that might still be navigating around in the parent directory.

    So what good is using the cfinclude method? Well, you can lock subdirectories to roles this way.

    <cfinclude template="../application.cfm">

    <cfif getAuthUser() eq "" or not IsUserInRole("Admin")>
    Access Denied!
    <cfabort>
    <cfif>


    Consider changing the DSN setting to use the request.scope to isolate the change to the user.
    <cfset Request.appDSN = "DININGHALL">
    Inspiring
    September 10, 2007
    What have you done to determine which application.cfm file is being
    used? Show some relevant code that demonstrates a reproducible problem.

    At this point all I can suggest is confirm that the file name is
    correctly spelled. A type in the name "application.cfm" will cause this
    file to never be read.

    September 10, 2007
    Application file in the subdirectory has the following in it:

    <cfset application.dsn = "DiningHall">


    -----------------------------------------

    Application.cfm in the root directory has:

    <cfset application.dsn = "campus_calendar">

    __________________________________________________________

    When I cfoutput APPLICATION.DSN IT shows "CAMPUS_CALENDAR", NOT "DININGHALL" and if I put the following in the subdirectory application.cfm file:

    <cfset application.dsn_test = "DiningHall"> and try to output, I get an error that it is undefined.

    But if I put <cfset application.dsn_test = "DiningHall"> in the root application.cfm, no error, prints out "DiningHall"

    Does that help clarify?