Distracto-boy meets layout=plain

I'm a huge fan of UI frameworks - particularly Twitter Bootstrap and jQuery UI - and I love making things look great - these frameworks really help me do that. Basically, I'm a wannabe designer. I admit it.

Some days, i just spend way too much time on getting those buttons, just right, or the right table or grid layout - it can be a time-sucker and I sometimes find myself behind on a deadline because I spent too much time pushing around the UI and not enough time building the "application" code. Enter: layout=plain.

In the CF Wheels framework, a Rails-like approach to CFML development, the base controller class (/controllers/Controller.cfc) has an init method where most folks handle all the pre-processing needed for all requests. We scaffold our CF Wheels apps from our  TroyWeb1 base-build - which includes a "filter" in the base controller to handle  initialization and cleansing of request parameters as well as setting up defaults for the built-in params used by wheels for layout and format.

<cfscript> firewall(); cleanseAndStrip(params); param name="params.format" default="html"; param name="params.layout" default=""; switch(params.layout) { case "plain": usesLayout("/plain"); break; default: usesLayout("/bootstrap"); } //end switch if(params.format EQ "xml" || params.format EQ "json"){ get("cfsetting").setEnablecfoutputonly(true); get("cfsetting").setShowdebugoutput(false); set(showDebugInformation=false); } </cfscript>

Like most app dev frameworks, CF Wheels leverages a front controller design pattern. That means all requests get routed through the same initial channel and that means certain things can easily be managed in that initial routing - like format and layout, which in CF Wheels are parameterized so the request can dictate what format needs to be returned. This is really great in the world of JSON feeds or other syndication streams. Thus, add ?format=json to the url and the plumbing to route your call to a json generating view is all built in. [checkout provides()] Layouts are managed this way too when combined with the usesLayout() controller method.

If you too are mesmerized by the shiny, candy-like buttons, join Distracto-boy in the fight. Create /views/plain.cfm with one line of code:

<cfoutput>#includeContent()#</cfoutput>

and simply change the default for params.layout to "plain"

param name="params.layout" default="plain";

and there ya go. Badabing! all those distractions are gone and you can focus on creating the app without all that glitter.