As you know (or may know) any custom tag can be called in both 'start' and 'end' mode. What does this mean? When CF encounters the following code:
<cf_foo>
lots of code
</cf_foo>
The custom tag foo will actually be run twice. Inside the tag, you can check to see which mode you are in by examining thisTag.executionMode. This technique allows for many cool custom tags, but that's not why I'm posting.
If you use cfmodule to call foo, you can still use 'wrappers' as I have defined above, you simply end the call with </cfmodule> instead of </cf_sometag>. However, if you have ANY cfmodule call inside your tag pair, CF can get confused by the </cfmodule> call. To get around that, you simply use a closing / at the end of the call:
<cfmodule template="..." />
However - this will execute your tag twice. So, how do you get around it? You could check executionMode like so:
<cfif thisTag.executionMode is "start">
lots of code
</cfif>
However, why wrap an entire tag in one big cfif? Instead, simply do:
<cfif thisTag.executionMode is "end"><cfexit></cfif>
This makes your code easier to read and simpler to debug.
Archived Comments
Hi, I have just started blogging and am using a site which allows users to create a blog. In other words, i don't have my own site. If you have any idea (which I am sure u must be having) can u gimme links to tutorials where I can get to know how to change the template of my blog using Macromedia Flash or something? I want a WYSIWIG interface as i don't know HTML. my url is http://twilight_fairy.redif.... Suggestions most welcome :-)
You can keep the end tag from even being processed by placing <cfexit method="exittag"/> at the end of the tag code (or inside the "start" section of the tag). When the tag is run, it will only run once then exit.
Paul, great idea there! I still prefer the use of a cfif above, but this is a good alternative, and one I didn't know of.