Templates are a fantastic time-saving tool. They allow you to create pages that share the same design but contain different content. If you modify a template document, you immediately update the design of all pages that were created from that template. Although first introduced in Dreamweaver 2.0, templates in later versions of Dreamweaver now make it possible for web developers (that is, template authors) to set up sophisticated rules for web site contributors so that they can add content to a site without any fear of compromising the site's design.
Dreamweaver templates are a special type of document that can be used to add structure and layout to a page. They enable you to ensure that all pages are rendered correctly in a variety of web browsers, such Microsoft Internet Explorer and Netscape Navigator. Designers and template authors now have tools to lock a page's layout, leaving unlocked areas ("editable regions") for content contributors to add their material.
Below you can see an example of an editable (left) and a locked (right) region:


Beginning with Dreameaver MX, template features give you complete control over a page's layout and content, which means you can define optional content, set up repeating regions, and define nested templates. I cover each of these topics below.
Using optional regions, you can define a section of the page that will or will not be shown, depending on what the content contributor decides. Optional regions are controlled by a conditional statement; the template tab of an optional region is preceded by the word "if." You create template parameters and expressions in the Optional Region dialog box or by typing parameters and conditional statements in Code view:

For example, suppose a fictitious online toy company called RU Playing wants to introduce a new range of action figures called Hoolibots. Each of the three figures shares the same page design but only one image is displayed on each of the pages.
Using an optional region, the template author can insert all three images on the template page and then let the content contributor control which of the actions figures is shown on each of the pages that is based upon this template.
Here's how you create an optional region:

Do one of the following:
Click the OK button. Your optional region should now look something like the screenshot show below.
As you can see from the image below, the region tab includes the word "if," which denotes that this is an optional region:
I have added two more images to the cell of this table, as shown below:

Having created a new page based on a template that contains a number of optional regions, content contributors can use the Template Properties dialog box to select which of the three images should be displayed on that page.
In the document window, choose Modify > Template Properties.

The word "true" appears in the Value column next to each of the images. This means that each image is currently visible on the page.
This changes the value of these two images to false, which prevents the document from displaying them.

The new document (see the screen shot below) now shows only Ksta:

After you have inserted an optional region into the template, you can still edit its settings:
In the document window do one of the following to modify the underlying code:
In the Property inspector, click Edit to open the New Optional Region dialog box:

Dreamweaver lets template authors create a section of a template that content contributors can easily duplicate. Although you can define many page elements as repeating regions, you typically use this feature with tables.
In my example, I use a repeating table to construct a data table that stores customer comments. Rather than having to guess how many comments will be present in the final table, you can just create enough table rows to finalize the design. The content contributor can then create a new page based upon this template and add as many rows as needed.
There are two templates tools that you can use to duplicate page elements:
For the purpose of this exercise, I'll concentrate on creating a table of customer comments for the RU Playing rocket, called the Cassandra V10. This screen shows how the completed repeating table looks:

Here's how you create it:
Place the insertion point in the document where you want to insert the repeating table and then do one of the following to bring up the Insert Repeating Table dialog box:
In the Ending Row field, also enter 2. This means that the repeating table initially will just have one repeatable row, as shown below. Content contributors will create additional rows as necessary.

Once you've created a template, it's easy to create new pages based on it:
Make sure the Update Page When Template Changes option is selected and then click the OK button.

Dreamweaver creates a new page based upon the template and looks something like the following:

Here's how you can move the rows around:

When you create a repeating table, all new rows inherit the same background color by default. With a small amount of hand coding, you can alternate these colors. In this example I use the following technique to alternate customer comments in the data table between white (hex value FFFFFF) and pale yellow (hex value FFFFCC) This results in the following customer comments data table:

To alternate row colors:
<!-- #TemplateParam name="evenColor" type="color" value="FFFFFF" --> <!-- #TemplateParam name="oddColor" type="color" value="#FFFFCC" -->
This results in the HEAD section looking something like this:

Next, select the first repeating row in your table:
While still in Code View, locate the following line of code:
<!-- TemplateBeginRepeat name="Editable content" -->
Replace it with the following code:
<tr bgcolor="@@((_index & 1) ? oddColor : evenColor )@@">
Your completed code should now look something like this.
When you save your amended template (using File > Save), Dreamweaver will prompt you in case you want to update any pages that are based upon that template:

Clicking the Update button then displays the Update Pages dialog box, shown below. Once updating is completed, the log will indicate how many pages were examined, how many pages were updated, and how many pages could not be updated.

If you now open a document that's based upon the template, you'll see that the background colors have been applied to your table rows. Try adding a couple of new rows. The first one will be white and the second one will be pale yellow.
A nested template is a template whose design is based on another template. By creating nested templates, you can control content in pages that share the same layout but have a few subtle design variations. In this example you will create a nested template based on an existing page layout from RU Playing's rocket club.
Below is a screen shot of the current template:

To construct a nested template:
In the Common toolbar of the Insert panel, click the Make Nested Template button on the Insert panel to save the page as a nested template:

Alternatively, you can choose File > Save as Template.
Add something in the new template. In this case, I'll add a new table that contains a map of Europe and add a new editable region called "Map."

Your nested template should now look something like the image below. The orange region indicates that you have created an editable nested region, inside of which is the new editable region called "Map." This tells you that only the region "Map" will be editable in any new pages you create from this nested template.

To change the region color from the default orange, choose Preferences > Highlighting and click on the appropriate color box (Nested Editable) to reveal the color palette. Using the eyedropper tool, select the new color and then click OK to close the Preferences dialog box. The new color will be applied immediately to both your templates and any pages that are based upon it.
Dreamweaver templates are an incredibly powerful feature for creating and managing consistent web designs and styles across large websites. Site designs can be created in templates and then propagated throughout the website, ensuring that all pages meet the style guides set down by the webmaster. As you have seen, the Dreamweaver templating architecture makes creating templates and managing pages based upon templates a breeze.