Two answers for price of one tonight.
>Dave,
>Are you saying that you are using Application.cfc to serve up your
>headers like folks used to do in the past? I am trying to understand
>how you would use Application.cfc for serving up your interfaces.
>-Aaron
For this example, your header & footer file are in a folder called common:
<cffunction name="onRequestStart" returnType="void" output="true">
<cfinclude template="common/header.cfm">
</cffunction>
<cffunction name="onRequest" returnType="void">
<cfargument name="thePage" type="string" required="true">
<cfinclude template="#arguments.thePage#">
</cffunction>
<cffunction name="onRequestEnd" returnType="void" output="true">
<cfargument name="thePage" type="string" required="true">
<cfinclude template="common/footer.cfm">
</cffunction>
At first glance, this may seem fine but after you try it you may notice it that
on some pages you don't want the header and/or footer included. You will end
up with cfif statements in the onRequestStart/stop functions to handle skipping
the includes for certain files or if you have something like skipheader = true
set.
For those reasons, I'd recommend against doing it this way. Senior Camden and
others have said this before but I had to learn why it was bad on my own.
For extending the application.cfc - Sean Corfield has an entry:
http://http//corfield.org/blog/index.cfm/do/blog.entry/entry/Extending_Applicationcfc
Basically, you do this:
Create a file called ProxyApplication.cfc that contains just these two lines:
<cfcomponent extends="Application">
</cfcomponent>
in your root directory (same directory as the application.cfc)
The filename doesnt matter but this name might make more sense to someone who
came in behind you.
Then in the subdirectory that you need to extend the application.cfc into,
create your application.cfc.
Example:
<cfcomponent output="false" extends="ProxyApplication">
<cffunction name="onRequestStart" returnType="void" output="false">
</cffunction>
<cffunction name="onRequest" returnType="void">
<cfargument name="thePage" type="string" required="true">
<cfinclude template="#arguments.thePage#">
</cffunction>
<cffunction name="onRequestEnd" returnType="void" output="true">
</cffunction>
</cfcomponent>
In this example, my main application.cfc has cflogin, session data, and a few
other checks that I don't need in the sub-directory. This above example
bypasses these checks by overwriting the onrequeststart, onrequest, and
onrequestend in the rootdir with these basic new functions.
This example would take the above cfc (that has header & footer in it) and then
skip the header & footer for anyfiles in sub-directory. The second
onRequestStart is used instead of the first one (in original application.cfc).
Any missing functions, such as OnApplicationStart, would be ran out of the
first application.cfc.
Make sense?
You are subscribed to cfcdev. To unsubscribe, please follow the instructions at
http://www.cfczone.org/listserv.cfm
CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]