Skip to main content
Participant
June 13, 2006
Question

Multiple Application files?

  • June 13, 2006
  • 3 replies
  • 378 views
Can you have more a second one in a sub directory?

/appication.cfm
/members/application.cfm

Can this work as long as you give the session a different name?
    This topic has been closed for replies.

    3 replies

    Inspiring
    June 13, 2006
    Another way of organizing multiple application.cfm files is to have one in the root directory with code that you want to always be executed. Other copies of application.cfm in subdirectories will contain code specific to their directory and will also, cfinclude the main application.cfm in the root directory.

    This means that the code in root/application.cfm will always get executed and subdirectory-specific code in the subdirectory/application.cfm will only get executed for files in that subdirectory.

    This is the approach that I've seen used most often.
    June 13, 2006
    If you are trying to have "application.cfm" files in subdirectories jdeline is absolutely correct. ColdFusion will only execute the first one it comes to in the directory tree. But, I have seen some coders have a root "application.cfm" file, and then have multiple "_application.cfm" in various subdirectories. The underscore at the beginning of the file name will put the file at the top of the list of files in the directory, and ColdFusion will ignore the file until you execute it. In the root "application.cfm" you can have some logic code (i.e., a CFIF statement) you can use to execute the appropriate "_application.cfm" file when you want it executed. For example, I've seen some coders have their CFIF statement look for a directory's name in the CGI.SCRIPT_NAME variable before it executes a CFINCLUDE for the "_application.cfm" file located in the desired subdirectory.
    June 13, 2006
    ColdFusion looks in the current directory for Application.cfm. If it finds it, it uses it. If it does not find it, it starts looking up the directory tree until it finds one. It does not look down to subdirectories.