Intermediate Dreamweaver

Basic HTML | Site management | Assets | Library of Page Elements| Find and Replace | Templates | Style Sheets | Forms | Imagemaps | Mouseovers | Flash buttons & text | Frames | Tables: Formatting & Sorting | Preview Browsers | Font Lists | Colors | Automating Tasks | Pasting in a Script

Templates

Templates are specialized files that define the basic design of your web page. Multiple pages can be created using each template, and the pages can easily be updated when the template is changed. Templates are also used when working with Macromedia Contribute.

You create a template that looks the way you want the pages to look. Parts that you don't want to change from one page to the next are marked as 'not editable'; parts that you do want to change are 'editable'. 'Optional' and 'Repeating' areas make it possible to group multiple instances of similar fields. When you want to create a new document using that design, you create a new page with that template specified, then edit the material in the editable regions. When you make changes to the template, Dreamweaver will duplicate them on all the pages using that template.

Templates can also be used to set up starter pages, where changes can be made to all regions and/or the pages are not updated when the template is updated.

Create the template

  • Start with an existing page that has the layout you want and delete the content in areas that will change, or create a new page, leaving the content areas blank.
  • Save the page as a template: choose Save As Template from the File menu
    Save in File menu
  • In the Save As Template Dialog box that comes up,
    Save as Template Dialog Box
    select the Site you want the template for, then in the Save As dialog box, enter a name for the Template (this will become the filename of the template as well).Click Save to complete the save operation.
  • Insert editable areas in the template:
    • Click or select where you want the editable area to be
    • From the Insert menu menu, choose Template Objects, then Editable Region:
    • Enter a name for the region:
      Name for the Region
    • The region will be displayed as text in curly brackets with a blue box around it and a blue tab showing the name.
      The text can be changed to indicate what content should be inserted in the region.
    • Repeat as necessary for all the editable regions you want to create.
  • Save again.

Note: when putting a link to a particular page into a template, it's best to use a fully-qualified (http://...) address for that link. Otherwise, you may need to copy the files into the template file to have the links work properly. Graphics used in the Template should appear both in the Template folder and in the root folder of the website.

Create new pages from the template:

  • from the File Menu, choose "New".
  • In the Templates For section, make sure the Site you are working in is selected
  • In the Site section, choose the name of the template you want to use.
  • Make sure Update Page when Template Changes is checked
  • Click Create.
  • Go to each editable region, select the text in it, and type or paste the content you want to appear there on the page you are working on: Editable region example
  • Once you have filled in all the Editable regions with their appropriate content (or deleted the text if you are not going put content in them), save the page in the Site folder

Repeat for all the pages you want to use that template. (Note: the pages do NOT have to have access to the template when uploaded.

Repeating regions

When you want to be able to have multiple instances of a set of editable regions-- for instance, in a departmental directory page, where you want to have names, office locations and phone numbers for multiple people-- you can place those editable regions inside a 'Repeating Region' in the template.

First create the Repeating Region by selecting the area and choosing Insert, Template Objects, Repeating Region.

(When trying to insert the region with its paragraph, list item, table row, etc., you may need to go into the code to be sure the Region is around, not inside, the area.)

Then click inside the repeating region and insert the editable regions. You may need to insert fake characters to separate your editable regions from the edges of the repeating one, but you can remove them after the region is created:

When using the template, to create another instance of the repeating region, click on the + sign next to the name of the Repeating Region:

To get a new instance after the one currently selected:

You can use the up and down arrows to move instances either up or down in relation to others, and the - to remove the currently selected instance.

Other Options

Templates can also contain Optional regions (which are only visible if another region's value meets the requirements), editable optional regions which the user can turn on and off, Repeating tables, and attributes of particular tags can also be made editable.

Editing the Template

  • To make changes to the template, open it, make changes, save it and when asked if you want to make the changes to all pages using this template, say yes. Dreamweaver will display a screen showing the pages being updated.

Notes about Templates: Templates are associated with Sites. However, Site setup does not migrate with the LAN space but has to be set up for each computer you use Dreamweaver. Templates are saved in directories with the site. So, if you put the directory you are working with in your LAN space, once you set up the Site on a computer with access to the LAN space, you will be able to use the Templates.

Adding updating dates via the template

You can combine the editable region and the date functionality to set up pages to have a last updated date that automatically updates itself whenever that particular page is updated.

  1. Insert a editable region where you want the date to appear.
  2. With the cursor in the editable region, choose Date from the Insert menu.
  3. Choose a date format, and make sure that 'Update Automatically on Save' is checked.
  4. Click OK.

Detaching a file from a template

Sometimes you may create a page with a template but not want to keep the 'template' areas sacrosanct and linked to the template. To detach the page from the template, from the Modify menu, choose Templates, then Detach from Template.

Changing templates

To change the template that a page uses, or apply a template to an existing page, go to the Modify menu, choose Templates, then Apply Template to Page.

Choose the template to apply.

If the region names in the new template don't match the region names in the old template-- or the page didn't previously use a template-- you will be asked which regions to put the content in:

Click on each region name and in the Move Content to New Region area, choose a region from the drop-down menu. Repeat this for all the regions that say 'Not Resolved'. Then click Ok.

 

February 10, 2004