Working with Dreamweaver Templates

 < Day Day Up > 



When two or more pages in a site use a common layout, it makes sense to create a master document — or template — that contains the shared elements to use as the basis of pages you build for a site. Dreamweaver templates take this concept much further with features for managing path structures, and updating pages, plus a whole range of options for designating both locked and editable elements in pages based on the template.

How templates work

Dreamweaver builds a special folder to hold template assets, as it does with library items. Templates are saved as .dwt files into a Templates folder that the program adds at the root level of the site. Special markup in HTML pages based on a Dreamweaver template allows the program to locate and update parts of pages when modifications are made in the template file.

Dreamweaver templates are like library items on a page level. But, whereas a library item is completely locked down, a template contains both locked and editable regions. Locked template regions can't be edited in pages based on the template — only specially designated editable regions may be individualized on a page-to-page basis. Optional and repeating areas may also be specified, if needed, to accommodate data-driven, dynamic pages based on a template.

Locked and editable regions affect only the pages that are based on the template; everything in a template file is editable. However, only changes made in locked regions of the template are updated in the related pages. This makes perfect sense when you think about it: Editable regions are not updated by the template because each page's editable regions probably contain page-specific content. Like library items, the code for pages based on a template is contained solely in the HTML page; the original template and Templates folder are not required on the web server. When you update pages based on a template, all modified pages must be saved and uploaded to the Web server for your published site to reflect changes you made.

Building a template from scratch

To begin a template from scratch, click the New Template button at the bottom of the Template Assets panel, which you can get to by clicking the page icon above the Library Assets book icon. You can also choose New Template from the Template Assets panel options.

Like library items, the first thing to do when you start a template is to name it. When the .dwt file opens, you can work within it as you would any HTML page, adding representative content and using any structure desired. As you build the page, keep in mind that you will be selecting areas, called regions, that will be editable. Conversely, some regions will be locked. Ultimately, it is far easier to choose these regions when your page is designed modularly.

Cross-Reference 

See Chapter 34 for more information about building modular layouts.

Building a template from an existing page

You may also create a template from an existing HTML document. To do this, open your document and choose File ® Save As Template in the dialog box that opens, and give the template a name.

With both methods, a templates folder is created at the root level of the site and the name of the template is used to name the .dwt file saved there.

On the CD-ROM 

Save the Habitat Alert37 folder from the chapter37_exercise folder to your hard drive. Define a new site. Hint: If you already have another Habitat Alert site defined, then choose the Edit Site option in the Site panel of the Site Definition drop-down menu and change the path to the Local Root folder. Just be sure that it's defined at the html level not the site level.

 Habitat Alert site   Most of the pages in the Habitat Alert site share the common interface found in the home page. The following steps show you how to build a template from it. As usual, be sure you have the site defined and are using the files from Chapter 37 before doing the exercise.

  1. Open the site/index.htm home page.

  2. Choose File ® Save As Template and name the Template Basic Page (see Figure 37-4). The site name will vary depending on how you have named your defined site.

    click to expand
    Figure 37-4: The Save As Template dialog box

  3. Click OK to save the template.

Caution 

The original page closes when the page is saved as a template. Be sure that you have saved the original page before this step, or changes made to the page will be lost.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

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