Working with Nested Templates Throughout this chapter, you've been getting familiar with Dreamweaver's template featurehope you're getting along with your new best friend! You've seen a lot of the flexibility of templates (and you'll see even more in the upcoming sections), but nothing else quite matches the ability to create nested templates. Put simply, a nested template is a document that controls pages in your site (just like a regular template), but which itself is under the control of another (master) template.A nested template is a document that controls pages in your site, but which itself is under the control of another template.Imagine this: You've set up a site whose pages are being driven by a template. Now you want a special section in the site that will use much of the same formatting as the rest of the site, but which also provides a formatting framework of its ownperhaps you want an online store within your site or a subsection that contains hands-on tutorials. You can set up a master template to handle the overall formatting of your site and then create a nested template to drive the formatting of your site's special section. When you make a change in your master template, that change then ripples down to your nested template and is applied to any pages that the nested template controls.You can set up as many nested templates as you wanttemplates controlling templates controlling templatesas many as you need to control the site you want to build.Nested templates allow you to create a second level of control in your web site. Normally, a master template controls the outermost page content (such as navigation controls and site-branding elements), while a nested template controls content within the page's main area. A page that's driven by the nested template contains content specific to that page, like text and graphics.[View full size image] To begin, you'll have to set up the master template. The master template can be a template that you've already created, or it can be a new, blank file.Here's how to set up a nested template:
1. | Open the file that you want to use as the master template; then choose File > Save as Template. | 2. | In the Save as Template dialog box that appears, use the Site pull-down menu to choose the site in which you want to save your template; then, in the Save As field, enter a name for your template. Click OK when you're done. | 3. | As you did earlier, insert any editable regions that you want in your template by selecting page content and choosing Insert > Template Objects > Editable Region.[View full size image] These editable regions will be the only editable areas in your nested template. All other areas of the page will be locked, just like locked areas in a regular template-driven page. | 4. | When you've created the editable regions that you want, choose File > Save.Now you're ready to create your nested template. | 5. | If it isn't already visible, open the Assets panel (choose Window > Assets); then click the Templates category button on the left. | 6. | In the Templates category of the Assets panel, select the template that will control your nested template; then from the Assets panel menu, choose New from Template. A new document is created with your template applied to it. | 7. | Choose File > Save as Template. In the Save as Template dialog box that appears, give your nested template a name; then click OK.A nested template is created automatically whenever you save a template-driven page as a template. Even though your page is now a template, you'll be able to edit only the content that resides in your master template's editable regions, as discussed earlier. Within the editable regions, you'll also be able to insert additional editable regions for the pages that will be driven by your nested template. You can also insert optional and repeating regions, which we'll talk about in the next section. | 8. | In the nested template, make any changes to the editable regions that you want and insert any editable regions that you need. When you're done, choose File > Save.[View full size image] As you begin inserting regions within your master template's editable regions, an orange outline appears around the master region, to help you distinguish between the editable regions in your master template and those in your nested template.If you don't insert any regions into your master template's editable regions, those regions remain outlined in blue, and they'll appear as editable regions in pages that are based on your nested template. In other words, they're passed through to the pages that are driven from your nested template. | 9. | Create a new page based on your nested template.You've already done this a few times. You can choose File > New and create a new document from the Templates tab, or you can select your nested template in the Assets panel and choose New from Template from the Assets panel menu. | 10. | On your new page, you can now make changes to the content that sits inside the editable regions that you set in your nested template or inside editable regions that are being passed through from the master template. |
 |