Experimenting with flashMessages() in CFWheels

August 4, 2010 · Chris Peters

I decided to experiment with a new function coming up in CFWheels 1.1 called flashMessages().

I decided to experiment with a new function coming up in CFWheels 1.1 called flashMessages().

In my layouts, I can reduce this logic:

<cfoutput>
<!--- Display error message from the Flash --->
<cfif flashKeyExists("error")>
<div class="error-message">
#flash("error")#
</div>
</cfif>
<!--- Display success message from the Flash --->
<cfif flashKeyExists("success")>
<div class="success-message">
#flash("success")#
</div>
</cfif>
</cfoutput>
view raw old.cfm hosted with ❤ by GitHub

To this line of code:

<cfoutput>
#flashMessages()#
</cfoutput>
view raw new.cfm hosted with ❤ by GitHub

This takes care of 80% of your potential usage of the Flash in CFWheels, and it reduces the logic to a single function call. Win!

About Chris Peters

With over 20 years of experience, I help plan, execute, and optimize digital experiences.

Leave a comment