> Yeah, is there really a CF_BodyContent that uses lists?  Sounds
> interesting,
> but I'm not really sure on what it would do.

Lee,

I don't know about lists, but I use a modified CF_BODYCONTENT that supports
an "array" attribute. When set to true, it creates (or appends to) a
request.bodycontent.myvariablename[x] array.

What it does is allow easy looping over generated content, which in turn
allows me to construct an app where presentation is isolated from logic. The
person working on presentation has the freedom to place page elements
wherever she likes, and is only required to vaguely understand two CFML tags
(CFOUTPUT and possibly CFLOOP). It works like this, basically:

- I don't use app_layout.cfm in any traditional way... all my layout stuff
is handled by tmp_ (template) files. There's a master tmp_ called
tmp_main.cfm, and then individual tmp_s that pair up with dsp_s... for every
dsp_showthis.cfm, there is a tmp_showthis.cfm.

- The dsp_ contains all the display logic, references to queries, and so on.
It's sole purpose is to create a series of variables to be used by the
subsequent tmp_. It creates those variables through standard CFSETs or
through individual calls to CF_BODYCONTENT when necessary.

- The tmp_ is a file full of HTML with a single CFOUTPUT wrapped around it.
Variables generated by the dsp_ are inserted, and where necessary, a CFLOOP
over a bodycontent array can be used.

So you end up with things like this:

---------
index.cfm
---------
<cfset request.app.template = "tmp_main.cfm">
....
<cf_bodycontent id="main">
....
<cfcase value="showthis">
        <cfinclude template="qry_showthis.cfm">
        <cfinclude template="dsp_showthis.cfm">
        <cfinclude template="tmp_showthis.cfm">
</cfcase>
....
</cf_bodycontent>
....
<cfinclude template="#request.app.template#">

----------------
dsp_showthis.cfm
----------------
<cfset request.bodycontent.username = "Bob">
<cfoutput query="qryShowThis">
        <cf_bodycontent id="rows" array="true">
                <a href="index.cfm?fa=doagain">#somedatabasecontent#</a>
        </cf_bodycontent>
</cfoutput>

----------------
tmp_showthis.cfm
----------------
<cfoutput>
        <h1>Greetings, #request.bodycontent.username#</h1>
        <table>
                <cfloop index="x" from="1" to="#Len(request.bodycontent.rows)#">
                        <tr><td>
                                #request.bodycontent.rows[x]#
                        </td></tr>
                </cfloop>
        </table>
</cfoutput>

------------
tmp_main.cfm
------------
<cfoutput>
        <html><body>
                This is the main template. Here's the content:
                #request.bodycontent.main#
        </body></html>
</cfoutput>


--
Roger


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to