Barney,
>Is there a way to, in the opening tag of a custom tag, tell the custom
>tag to skip evaluation of it's body?
>
><p:mytag>
> i don't want to do this
></p:mytag>
>
>mytag.cfm:
><cfif this.executionMode EQ "start">
> <cfexit method="goToJustAfterClosingTag" />
></cfif>
You should be able to do cancel the entire request:
<cfif this.executionMode EQ "start">
<cfexit method="exitTag" />
</cfif>
I wrote a cf_CacheObject tag a long time ago which I used to cache a bunch
of code that really CPU intensive. Here's the code (please forgive the
uppercase--I wrote the code 4 years and a week ago):
<CFSETTING ENABLECFOUTPUTONLY="NO">
<!--------------------------------------------------------------------------
---
Name: CF_CacheObject
Author: Dan G.Switzer, II <[EMAIL PROTECTED]>
Company: PengoWorks.com
Date: August 17, 2001
Build: 100
Description:
This tag will is used to cache an object and/or partial content on a page.
The object can be any valid ColdFusion variable that will be available
by the time the end tag runs. This is extremely useful for caching objects
that take a lot of process to generate, but in which the output of the
object may change. You'll need to have access to the "Application" scope.
Attributes:
Action - The action you'd like to perform. Valid options are "Cache"
and "Clear". (Required)
Object - The object to cache. (Optional)
CachedWithin - The timespan to cache the object. Defaults to 30 minutes.
Uses the CreateTimeSpan function. (Optional)
----------------------------------------------------------------------------
-->
<!---// set default attributes //--->
<CFPARAM NAME="Attributes.Action" TYPE="String" DEFAULT="Cache">
<CFPARAM NAME="Attributes.Object" TYPE="String" DEFAULT="">
<CFPARAM NAME="Attributes.CachedWithin" TYPE="Numeric"
DEFAULT="#CreateTimeSpan(0, 0, 30, 0)#">
<!---// define local variables //--->
<CFSET sHashKey = CGI.SCRIPT_NAME>
<!---// lock all calls to tag, to prevent any errors //--->
<CFLOCK TIMEOUT="60" THROWONTIMEOUT="No" NAME="cfCacheObject"
TYPE="EXCLUSIVE">
<CFIF NOT IsDefined("Application.cfCacheObject")>
<CFSET Application.cfCacheObject = StructNew()>
</CFIF>
<CFIF NOT StructKeyExists(Application.cfCacheObject, sHashKey) OR
NOT CompareNoCase(Attributes.ACTION, "Clear")>
<CFSET Application.cfCacheObject[sHashKey] = StructNew()>
<CFSET Application.cfCacheObject[sHashKey].GeneratedContent
= "">
<CFSET Application.cfCacheObject[sHashKey].Object = "">
<CFSET Application.cfCacheObject[sHashKey].LastUpdated =
Now()>
<CFSET Application.cfCacheObject[sHashKey].Expires =
Application.cfCacheObject[sHashKey].LastUpdated>
</CFIF>
</CFLOCK>
<CFSWITCH EXPRESSION="#Lcase(ThisTag.ExecutionMode)#">
<CFCASE VALUE="start">
<!---// if the object hasn't expired, then grab the cache
//--->
<CFIF DateCompare(Now(),
Application.cfCacheObject[sHashKey].Expires) EQ -1>
<CFSET isExpired = False>
<CFIF NOT Len(Attributes.Object)>
<CFSET SetVariable("Caller." &
Attributes.Object, Application.cfCacheObject[sHashKey].Object)>
</CFIF>
<CFOUTPUT>#Application.cfCacheObject[sHashKey].GeneratedContent#</CFOUTPUT>
<CFEXIT METHOD="EXITTAG">
<!---// if the object has expired, the process on end tag
//--->
<CFELSE>
<CFSET isExpired = True>
</CFIF>
</CFCASE>
<CFCASE VALUE="end">
<CFSET Application.cfCacheObject[sHashKey].GeneratedContent
= ThisTag.GeneratedContent>
<CFIF NOT Len(Attributes.Object)>
<CFSET Application.cfCacheObject[sHashKey].Object =
Duplicate(Evaluate("Caller." & Attributes.Object))>
<CFELSE>
<CFSET Application.cfCacheObject[sHashKey].Object =
"">
</CFIF>
<CFSET Application.cfCacheObject[sHashKey].LastUpdated =
Now()>
<CFSET Application.cfCacheObject[sHashKey].Expires =
CreateODBCDateTime(Application.cfCacheObject[sHashKey].LastUpdated +
Attributes.CachedWithin)>
</CFCASE>
</CFSWITCH>
<CFSETTING ENABLECFOUTPUTONLY="NO">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:216295
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54