Why use CFDIRECTORY when you can use try/catch blocks?  Here's how I
approached the "is the include there" problem in one of my apps:


<cftry>
  <img src="#request.app.path#images/spacers/trans.gif" width="12"
height="4" /><img src="#request.app.path#images/spacers/trans.gif"
width="146" height="4" /><br><span class="navHeader">News &amp;
Events</span>
  <cfinclude template="/generated/related_links.txt"><br>
  <cfcatch type="MissingInclude">
   <!--- If the include file is missing, try to write it again... --->
   <cftry>
    <cfinclude template="/_admin_tools/related_links_to_text.cfm">
    <!--- Give the include file time to be written...in this case, 2
seconds. --->
    <cfset lockname = CreateUUID()>
     <cflock name="#lockname#" type="readonly" timeout="0">
      <cftry>
       <cflock name="#lockname#" type="exclusive" timeout="2"></cflock>
      <cfcatch type="lock"></cfcatch>
      </cftry>
     </cflock>
    <!--- And then, try the include again... --->
  <img src="#request.app.path#images/spacers/trans.gif" width="12"
height="4" /><img src="#request.app.path#images/spacers/trans.gif"
width="146" height="4" /><br><span class="navHeader">News &amp;
Events</span>
    <cfinclude template="/generated/related_links.txt"><br>
    <!--- If it's still missing, just do nothing --->
    <cfcatch type="missinginclude">Missing Include Error</cfcatch>
   </cftry>
  </cfcatch>
  <cfcatch type="Any">Unknown error</cfcatch>
 </cftry>


Works like a charm, no more missing include errors.

Pete

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, November 06, 2002 9:40 AM
Subject: Using CFDirectory on every page


> Is there a unacceptable performance hit if I were to use cfdirectory
> on every page of my site?
>
> What I want to do is look in each directory for an include and
> if it isn't there look for that include in the parent directory.
> This will allow me to use the same include for an entire section
> but will give me the ability to overide that include for a sub-section
> if needed.
>
> David Murphy
> www.cfugcny.org
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to