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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
To this line of code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
#flashMessages()# | |
</cfoutput> |
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!