# ViewCollection

In a .CFM template used as a View in a Model-Glue Application, the "viewcollection" variable gives access to the rendered results of prior views.

This can be used to "stack" views. The following example shows a simple event handler in which one view, dspBody.cfm, is used inside of another (dspTemplate.cfm):

<!-- In ModelGlue.xml -->

<event-handler name="viewstacking">

<views>

<include name="body" template="dspBody.cfm" />

<include name="main" template="dspTemplate.cfm" />

</views>

</event-handler>

<!--- dspBody.cfm --->

Hi, I'm dspBody.cfm!

<!--- dspTemplate.cfm --->

<h1>dspTemplate.cfm</h1>

<cfoutput>#viewcollection.getView("body")#</cfoutput>