0

ColdFusion Tag of the Week: CFSAVECONTENT

ColdFusion Tag of the Week

Inspired by a recent post over at <cfsilence> and a handout Dave gave us at the last DFWCFUG meeting I decided I wanted to start a blog series. With this series of posts I hope to highlight a ColdFusion tag or function that people may have forgotten about or may not ever use. Or I may even highlight a tag that a lot of people use and that more should be aware of, <cfqueryparam> comes to mind. I will also use these posts to highlight codeShare, a project that Fro and I worked on and that Dave and Aaron did a great job integrating into InstantSpot . If you ever need to share code with someone over the Internet codeShare is a perfect place to do it. If you have any suggestions for a tag to highlight shoot me an email at ryan DOT Everhart AT gmail DOT com.

This may or may not get as loyal of following as Andy Jarrett’s Friday Jokes, but it’s worth a shot! So with out further delay the first every ColdFusion Tag of the Week!

This week’s tag is a tag that I’ve been using a lot of lately when writing AJAX with Rob Gonda’s ajaxCFC.

The Tag:
<cfsavecontent>

The Definition:
Saves the generated content of the cfsavecontent tag, including the results of evaluating expressions and executing custom tags, in the specified variable.

The Tag Sample:

The Real Life Example:

 

The Uses:
Like I mentioned above I use this a lot when working with AJAX. It allows me to write HTML code and send it back to the user thru javascript as a string.  This is MUCH easier than trying to write HTML code using javascript. Another use for it may be to create content for use in a <cfmail>.   There are some situations where you may need to output more than one query within a <cfmail> tag and its not always possible.  However with <cfsaveconent> it is possible, in fact your <cfmail> tag may even look a bit cleaner if you use <cfsaveconent>

 

 

 

The Bonus Code:

Good Day!
Ryan

Sam Farmer said:
 
Great idea for a series...

cfsavecontent is an extremely useful tag.
 
posted 612 days ago
Add Comment Reply to: this comment OR this thread
 
Michael White said:
 
I use this tag in flash forms to hold actionscript code but I also use it in email notification pages because it's a good way to spit out a table with repeating rows that use the group by clause
 
posted 612 days ago
Add Comment Reply to: this comment OR this thread
 
 
Thanks Sam!
 
posted 612 days ago
Add Comment Reply to: this comment OR this thread
 
Travis Trumbo said:
 
Thanks for the tip, I have been looking for a clean solution to output multiple queries in a cfmail tag and this looks pretty good!
 
posted 426 days ago
Add Comment Reply to: this comment OR this thread
 
 
Travis,
Glad to help! CFCONTENT is perfect for that, good luck!
 
posted 424 days ago
Add Comment Reply to: this comment OR this thread
 
Bee said:
 
Been trying to figure out a way to use multiple queries within a cfmail and this idea is just great and perfect.
Thanks
 
posted 102 days ago
View Replies (1) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
ev said:
 
Bee glad to help! Good luck!
 
posted 102 days ago
Add Comment Reply to: this comment OR this thread
 

Search