Applying a Template


After you have your template created and saved, you'll probably want to start creating pages based on it. Before you start generating pages, though, you need to know a few things about templates and their child pages.

As I mentioned earlier, the templates created for your site are located in a subfolder of your site root called Templates. It's important that you don't rename or move that folder, or you won't be able to automatically update pages that are reliant on templates.

In addition, when you make changes to the pages and templates within your site, you need to be sure that you not only transfer child pages, but also transfer the template file to the server if it has been modified, so that the child pages can be viewed correctly.

Lastly, you should be aware that creating pages based on templates can add quite a bit of code to your pages and more code means slower load times. If you are building a website that needs to be accessed via dial-up connections and the site has a complex layout, you need to balance the slower load times with the benefits that templates offer for site maintenance.

Creating New Pages from Your Template

Creating a new child page from a template is similar to creating any other new file and can be done by choosing File, New from the menu bar. In the New Document dialog box, however, select the Templates tab (see Figure 27.11), where Dreamweaver displays all of your different sites and the templates that are stored associated with them.

Figure 27.11. The New from Template dialog box enables you to select from the available templates associated with your site.


To create a new child page, select the template on which you want to base it and click Create. Dreamweaver creates a new page and indicates that it is based on a template by placing Template: and the name of the source template in the upper-right corner of the page (see Figure 27.12).

Figure 27.12. A new child page has been created based on the template.


In addition, if you switch to Code view (see Figure 27.13), you'll notice that the majority of the code for the site is grayed out. Because these regions are locked by the template, you can't adjust them in either Design or Code view.

Figure 27.13. The code is locked by the template.


To make changes to the child page, adjust the content of the editable regions on the template and then save the page.

Applying Templates to Existing Pages

If you want to bring existing pages into your template/child page structure, Dreamweaver offers a tool to assist with the process. The benefit is that all the pages in your site can be based on a template, which means that your entire site can be updated through template updates.

Be aware, however, that to successfully apply a template to an existing page, you need to do some work to ensure that the existing page already has the same structure as the template. Trying to apply a template to a page that is structurally different really doesn't work. Keep in mind that the goal here isn't to have Dreamweaver modify the structure of your existing pagesthings go bad when you ask Dreamweaver to mesh two different pages' structures. The goal, instead, is to ensure that all pages that do have the same page structure can be updated via the template.

To apply a template to an existing page, open the page and choose Modify, Templates, Apply Template to Page from the menu bar. As shown in Figure 27.14, the Select Template dialog box enables you to choose from the available site templates. Choose the appropriate template and check the box indicating that the page should be updated when the template is changed.

Figure 27.14. The Select Template dialog box enables you to choose which template to apply to the page.


Click Select and Dreamweaver presents you with any content that might not fit into the template schema, and enables you to determine how to deal with the existing content prior to the application of the template (see Figure 27.15).

Figure 27.15. Indicate which editable regions should be used for any existing content.


To apply the template, click OK and the template regions and markup code are added to the page.



Special Edition Using Macromedia Studio 8
Special Edition Using Macromedia Studio 8
ISBN: 0789733854
EAN: 2147483647
Year: 2003
Pages: 337

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net