| 3 | | In Quickstart 5, we looked at how <result> tags with a NAME attribute can be used to conditionally run other event handlers. |
| 4 | | |
| 5 | | However, what if we always want to run an additional event handler? Easy: don't give it a NAME attribute. |
| 6 | | |
| 7 | | If you look at your !ModelGlue.xml file, there's an event handler named "template.main". It doesn't do much: no messages, no results, just a single <include>. |
| 8 | | |
| 9 | | The include, though, is special. Open it up. (/translator/views/templates/main.cfm). |
| | 3 | Model-Glue ships with a default template, which is really just another view file. This view, though, is special. Open it up. (/translator/views/templates/main.cfm). |
| 29 | | I'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! |
| | 26 | Next, we indicate that we want to add some common functionality that will occur after our event-handler is processed: |
| | 27 | |
| | 28 | {{{ |
| | 29 | |
| | 30 | <event-types> |
| | 31 | <event-type name="templatedPage"> |
| | 32 | <after> |
| | 33 | </after> |
| | 34 | </event-type> |
| | 35 | </event-types> |
| | 36 | |
| | 37 | }}} |
| | 38 | |
| | 39 | Then we add our template view to the event type: |
| | 40 | |
| | 41 | {{{ |
| | 42 | |
| | 43 | <event-types> |
| | 44 | <event-type name="templatedPage"> |
| | 45 | <after> |
| | 46 | <views> |
| | 47 | <include name="main" template="templates/main.cfm" /> |
| | 48 | </views> |
| | 49 | </after> |
| | 50 | </event-type> |
| | 51 | </event-types> |
| | 52 | |
| | 53 | }}} |
| | 54 | |
| | 55 | Finally, we use the "type" attribute of the event-handler tag to apply the new type to our events, so they now look like this: |
| | 56 | |
| | 57 | {{{ |
| | 58 | |
| | 59 | <event-handler name="translationForm" type="templatedPage"> |
| | 60 | <views> |
| | 61 | <include name="body" template="frmPhrase.cfm"> |
| | 62 | <value name="xe_translate" value="translationFormAction" /> |
| | 63 | </include> |
| | 64 | </views> |
| | 65 | </event-handler> |
| | 66 | |
| | 67 | <event-handler name="translationFormAction" type="templatedPage"> |
| | 68 | <broadcasts> |
| | 69 | <message name="NeedTranslation" /> |
| | 70 | </broadcasts> |
| | 71 | <views> |
| | 72 | <include name="body" template="dspPhrase.cfm"> |
| | 73 | <value name="xe_translationForm" value="translationForm" /> |
| | 74 | </include> |
| | 75 | </views> |
| | 76 | <results> |
| | 77 | <result name="ValidationError" do="translationForm" redirect="true" /> |
| | 78 | </results> |
| | 79 | </event-handler> |
| | 80 | |
| | 81 | }}} |
| | 82 | |
| | 83 | [http://localhost/translator/index.cfm?event=translationForm Browse to the site again], and you should see the default template "wrapping" the views. |
| | 84 | |
| | 85 | Congratulations, you've finished the Quickstart! |