Changes between Initial Version and Version 1 of QuickStart/6:AddingaSiteWideTemplate

Show
Ignore:
Timestamp:
04/15/09 19:43:31 (17 years ago)
Author:
trac (IP: 127.0.0.1)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • QuickStart/6:AddingaSiteWideTemplate

    v1 v1  
     1= Quickstart 6: Adding a Site-Wide Template = 
     2 
     3In Quickstart 5, we looked at how <result> tags with a NAME attribute can be used to conditionally run other event handlers. 
     4 
     5However, what if we always want to run an additional event handler? Easy: don't give it a NAME attribute. 
     6 
     7If you look at your !ModelGlue.xml file, there's an event handler named "view.template." It doesn't do much: no messages, no results, just a single <include>. 
     8 
     9The include, though, is special. Open it up. (/translator/views/dspTemplate.cfm). 
     10 
     11See Line !#13? "viewcollection.getView('body')"? What's with that? 
     12 
     13Model-Glue makes it easy to display the rendered HTML from one view inside of another. In all of your .CFM view templates, a variable named "viewcollection" is available. To display the rendered HTML from a prior view, simply run getView(), passing it the value of the desired view's NAME attribute. 
     14 
     15In English: because we named our <include> for frmPhrase.cfm and dspPhrase.cfm "body", we could use this event-handler to display a "wrapper" around their content. 
     16 
     17If only we could tell Model-Glue to run the view.template event handler after translationForm and translationFormAction. 
     18 
     19Well, we could use a result tag, give it a name of "doTemplate," and always add the result in a Controller function. But that'd be tedious. 
     20 
     21Instead, we can use an ''unnamed'' result. Any unnamed result is considered "implicit," and will always be executed. 
     22 
     23So, if we add the following <result> tag to our !ModelGlue.xml event handlers for the translation form and its action page, we can cause the view.template event handler to execute: 
     24 
     25{{{ 
     26<result do="view.template" /> 
     27}}} 
     28 
     29I'd show you the XML, but I '''did''' say there was a quiz at the end. When you've added the result and gotten the sitewide template to work, you've finished the Quickstart!