Changes between Version 1 and Version 2 of Training/Section02
- Timestamp:
- 12/29/09 20:35:56 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Training/Section02
v1 v2 11 11 Click on the This Template link and our template will display in your browser. This template can be portioned off into 6 sections: 12 12 13 *Navigation – Contains the logo and the navigation14 *Primary Content – Contains the general content for the user15 *Secondary Content – Contains any secondary content in a 2 column format16 *Footer – Contains footer content17 *Message Box – Contains messaging to notify the user of status or error conditions18 *Master Page – Contains the general page layout structure and includes the above 4 elements.13 1. Navigation – Contains the logo and the navigation 14 2. Primary Content – Contains the general content for the user 15 3. Secondary Content – Contains any secondary content in a 2 column format 16 4. Footer – Contains footer content 17 5. Message Box – Contains messaging to notify the user of status or error conditions 18 6. Master Page – Contains the general page layout structure and includes the above 4 elements. 19 19 20 20 [[Image(training02-1.png, nolink)]][[BR]] 21 21 '' The above diagram shows the content sections and the file in which each will reside '' 22 22 23 == = Making the Modules ===24 25 *Open the file /template.html and review the contents. Each section has been marked out for you with HTML comments. For example, the following section of code indicates the boundaries for the specific content.26 *Create a new file using the name indicated (views/layout/Layout.Navigation.cfm) and copy the content in between the comments into the newly created file. Do this for each section.23 == Making the Modules == 24 25 1. Open the file /template.html and review the contents. Each section has been marked out for you with HTML comments. For example, the following section of code indicates the boundaries for the specific content. 26 2. Create a new file using the name indicated (views/layout/Layout.Navigation.cfm) and copy the content in between the comments into the newly created file. Do this for each section. 27 27 28 28 '' Example of the boundaries for specific content '' … … 40 40 }}} 41 41 42 == = One Master to Rule Them All ===42 == One Master to Rule Them All == 43 43 44 44 Open /PlantOMatic/views/layout/Master.Layout.cfm and review the code. Master.Layout.cfm contains !ColdFusion and HTML source code and represents the high level structure of our application – it is primarily in charge of assembling our content modules. We get our content from the !ViewCollection and output it on the screen. The calls to the !ViewCollection are together at the top of the file: … … 65 65 }}} 66 66 67 == = Putting it all Together ===67 == Putting it all Together == 68 68 69 69 Our last task in skinning is to create a reusable mechanism to use our layout. Model-Glue 3 introduces the concept of an Event Type. Much like Types in Object Oriented Programming, an Event Type contains specific behavior and is addressable by a specific name. Event Types in Model-Glue can contain behavior that is executed BEFORE, AFTER or BEFORE and AFTER an Event is executed. … … 112 112 }}} 113 113 114 == = A Flexible One Column Template ===114 == A Flexible One Column Template == 115 115 116 116 Now, when we run our application at [http://localhost/PlantOMatic/ http://localhost/PlantOMatic/] we see our template in action: … … 119 119 '' One Column Layout '' 120 120 121 == == What about Two Columns? ====121 == What about Two Columns? == 122 122 123 123 To see the benefits of this flexible template, let's add a piece of secondary content. Open /PlantOMatic/config/ModelGlue.xml and update the default Event Handler to have an include for secondary: … … 136 136 Now when our Event Handler runs, Model-Glue will include the secondary content inside of the ViewCollection. Since we test for the existence of secondary in /PlantOMatic/views/layout/Master.Layout.cfm and adjust the HTML markup accordingly, the simple presence or the absence of secondary in the ViewCollection will turn our layout from a single column to a two column layout seamlessly. 137 137 138 == = A Flexible Two Column Template ===138 == A Flexible Two Column Template == 139 139 140 140 [[Image(training02-3.png, nolink)]][[BR]] 141 141 '' Two Column Layout '' 142 142 143 == == Housekeeping ====143 == Housekeeping == 144 144 145 145 We have a few items to take care of before we move on. 146 146 147 *Open /PlantOMatic/views/layout/Layout.Navigation.cfm and replace the content:147 1. Open /PlantOMatic/views/layout/Layout.Navigation.cfm and replace the content: 148 148 149 149 {{{ … … 162 162 }}} 163 163 164 *Open /PlantOMatic/views/layout/Layout.MessageBox.cfm and replace the content:164 2. Open /PlantOMatic/views/layout/Layout.MessageBox.cfm and replace the content: 165 165 166 166 {{{ … … 185 185 }}} 186 186 187 == = Section 2 Summary ===187 == Section 2 Summary == 188 188 189 189 In this section, we learned how to skin a static template, work with the Model-Glue framework to create a flexible layout and configure our Event Handlers for templating. For more information, we suggest the following documentation:
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)