Using Templates

     

After your template layout is defined, you're ready to use it to create your site. You can use a template in one of two ways:

  • Create a new document from a template.

  • Apply template changes to an existing document.

Creating a New Page from a Template

The most common way to use a template is to create a new document in a site. A new document is created just like any other, but the document's content contains the template code along with any regions that are editable. If an editable region had text or other content in it in the template, that content is also included in the document.

To create a new page from the template, do one of the following:

  • Select File, New from the document menu, and click the Templates tab in the dialog box. Select the site and a template (see Figure 6.24).

    Figure 6.24. The New from Template dialog box lets you browse your sites for templates. It shows a thumbnail preview of the template to make finding the one you are looking for easier.
    graphics/06fig24.jpg

  • Select a template from the Templates category of the Assets panel. (Control-click) [Right-click] the selected template to bring up the context menu. Select the New from Template option.

graphics/troubleshooting_icon.jpg

Controlling highlighting for templates is something you might want to do. See "Highlighting Template Code" in the "Troubleshooting" section at the end of this chapter.


Making Changes to the Page

After you have a document created with the template, editing it is a lot like editing any other document. The only difference is that you can modify only the content of the editable portions of the page.

To change content in an editable region, simply click the region and enter the new content. You can use any of the Dreamweaver editing features in this content region.

Repeatable regions have additional options. On the right side of the Region tab, you have the option to add, remove, or select a new repeating section.

Applying a Template to an Existing Page

Although creating new pages that automatically use a template layout is what templates are primarily about, it is also nice to be able to take an existing document and apply a template layout to it. Dreamweaver enables you to do this, and it does so by attempting to match the page content with the regions of the template.

Pages originally created with a previous version of the template are likely to have some regions that match the new template. Dreamweaver matches these regions automatically.

If you apply the template to a document that doesn't have matching editable regions, Dreamweaver allows you to select a template region to apply mismatched content to or to delete content that doesn't match. To apply a template to an existing document, do this:

  1. Open the document to which you want to apply the template by using the Files panel or by selecting File, Open from the Document menu.

  2. Select Modify, Templates, Apply Template to Page from the Document menu. You can also select a template in the Templates category of the Assets panel and click Apply, or you can drag a template from the Assets panel to the document.

  3. If there is content that can't be matched to a template region, the Inconsistent Region Names dialog box is displayed (see Figure 6.25).

    Figure 6.25. When you apply a template to an existing page, the Inconsistent Region Names dialog box lets you choose which region of the template to use for existing content.
    graphics/06fig25.jpg

  4. Select an editable region from the list. Then, using the Move Content to New Region drop-down menu, select a template region into which Dreamweaver should move the content.

  5. Repeat step 4 for other editable regions of the document.

  6. Click OK.

graphics/troubleshooting_icon.jpg

Detaching a template is possible, too. See "Detaching a Template" in the "Troubleshooting" section at the end of this chapter.


Editing a Template

Editing a template is similar to editing any other document. Double-click the template in the Assets panel to open it in the editor, or select it in the list and click the Edit button.

After you've made changes to a template, you need to apply the changes to any document that uses the template. If you specified the option to automatically update a page, the Update Template Files dialog box appears when you save the template and gives you the option of updating or not updating pages in your site. If you don't have a page marked to automatically update, apply the template to it by using the Apply button in the Assets panel. Any editable regions that can't be matched to regions in the new template cause the Inconsistent Region Names dialog box to be displayed.

You can use the Update Pages dialog box to quickly apply a template to all pages that use it in your site. To use this dialog box, do the following:

  1. Select Modify, Templates, Update Pages. The Update Pages dialog box appears (see Figure 6.26).

    Figure 6.26. The Update Pages dialog box enables you to quickly apply a template to any template pages on your site.

    graphics/06fig26.jpg


  2. Select one of the following options:

    • Entire Site ” Select this option in the Look In list to update an entire site; then select the site in the drop-down list.

    • Files That Use ” Select this option in the Look In list to update only those pages that use a particular template file, then select the appropriate template from the drop-down list.

  3. Leave the Show Log check box checked to see the changes that are made to your pages.

  4. Click Start to update the pages.

The log window shows the pages that were updated. If any errors occurred in the update, they are shown in the log's status window as well.



Using Macromedia Studio MX 2004
Special Edition Using Macromedia Studio MX 2004
ISBN: 0789730421
EAN: 2147483647
Year: N/A
Pages: 339

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