Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy Question

Status
Not open for further replies.

jt8941

Programmer
Dec 9, 2003
15
0
0
US
Is there a way to not have the application.cfm file run when you visit a .cfm page?
 
Not really (unless you don't have an application.cfm file at all), but you can make it so the CODE in the application.cfm doesn't run when you visit a page. Just use an IF statement to check and see what page is being loaded. IF it's NOT the page you want to exclude, process the code in application.cfm, if it IS the page, skip the processing and do nothing.

Try this in your application.cfm:
<cfif GetFileFromPath(GetTemplatePath()) NEQ &quot;Page.cfm&quot;>
...Whatever code you want to execute...
</cfif>


Hope This Helps!

Ecobb

&quot;Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.&quot; - Homer Simpson
 
You can also put the folder in a sub folder in the site and put a different Application.cfm file in the subfolder. When CF executes a page, it looks for that file in the current folder. When not found, it continues to move up directories until it hits the Root folder of the site where one 'should' be there.

- Mike

Dicover Pura Vida 'The Pure Life' in Costa Rica -
 
Mike's got it.

Put your .CFM page in a subdirectory, an create an essentially blank Application.cfm in that same directory... something like:
Code:
  <!--- blank application --->
(if memory serves, ColdFusion chokes if your Application.cfm is truly zero k/no characters... so just adding a ColdFusion comment is the work-around.

Then, when you hit the .CFM page in that subdirectory, your master/global Application.cfm won't run because it found one in that subdirectory.

While Ecobb's method works, it is a maintenance nightmare as you start adding more and more pages that shouldn't run the Application.cfm, or you're editing &quot;Page.cfm&quot; somewhere else on your site and you're banging your head against the wall because you can't figure out why it's behaving strangely.



-Carl
 
You could wrap your application.cfm file within this:

<cfif NOT IsDefined(&quot;__application_cfm&quot;)>
<cfset __application_cfm = 1>

.
.
.
.

</cfif>

This way, it will only run the code inside the <cfif> the first time the application.cfm is called. Plus, if you ever need to force it to be read again, just undefine the variable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top