Jesse Houwing wrote:
>>Yes, not quite as easy as in php though. The logic I've used before goes
>>something like:
>>
>><cfparam name="request.included" default="false" type="boolean">
>>
>><cfif not request.included>
>> <cfinclude template="mytemplate.cfm">
>> <cfset request.included = true>
>></cfif>
>>
>>
>>
>>
>We used a customtag that is called and that in turn includes the
>requested include.
>
>so like:
>
><cf_include_once template="template.cfm" />
>
>and the contents of the cf_include_once customtag:
>
<snip content="code with some errors">
>Thsi isn't copy-pasted, but typed right here from what I remember
>(currently ill at home) so it may need some tweaking.
>
>Jesse
>
>
Ok, I created and tested this at home :)
This is the code required:
<!--- start include_once.cfm --->
<cfif not ThisTag.executionmode is 'End'>
<cfexit method="exittemplate" />
</cfif>
<cfif not isDefined("request.included")>
<cfset request.included = structNew() />
</cfif>
<cfif not StructKeyExists(request.included, attributes.template)>
<cfif >
<br> including: #attributes.template#
</cfoutput>
<cfinclude template="#attributes.template#" />
<cfset request.included[#attributes.template#]=true />
</cfif>
<!--- end include_once.cfm --->
Tested and verified it. There is one small problem though, I found that
if you include a file into itself the Coldfusion service immidiately
restarts. This should not happen, but I haven't been able to prevent it.
Jesse
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4