Templates and the Assets Panel


As your site grows, so too will the number of templates it employs. In general, overall management of site templates is handled by the Templates category in the Assets panel, shown in Figure 15.21.

Figure 15.21. Use the Templates category in the Assets panel to manage site templates.


The Assets panel is separated into the following areas:

  • Template list: Displays a list of DWT files or templates in a defined site. The list provides the name of the template, its size in kilobytes, and the path (usually in the Templates folder of the defined site).

  • Template preview: Displays a preview image of the template.

  • Apply: Applies a selected template to an existing design in the Document window. This button is covered with more detail later in the chapter.

  • Refresh Site List: Refreshes the template category to reflect changes made within the Files panel.

  • New Template: Creates a new DWT file in the Templates folder of your defined site. When this button is clicked, a new template instance appears in the template list.

  • Edit: Click this button to launch the selected template from the template list in a new Document window for editing.

  • Delete: Deletes a selected template.

  • Options menu: Displays advanced options for working with and managing templates. These options are outlined with more detail in the following discussion.

For the most part, general management of site templates can be handled through the small button bar that appears at the bottom of the Template category in the Assets panel. For more advanced options, however, access options located in the panel's Options menu:

  • Refresh Site List: Refreshes all templates in the template list.

  • Recreate Site List: Reloads the template site list into the site cache.

  • New Template: Select this option to start a new blank template.

  • Edit: Opens the selected template in a new Document window instance for editing.

  • Apply: Select this option to attach a template to a page that isn't derived from a template. Dreamweaver asks you to map template regions to areas on the page. More on this later.

  • Rename: Allows you to rename the selected template.

  • Delete: Deletes a selected template.

  • Update Current Page: Applies any changes made in a template to the current page assuming that page is derived from the modified template.

  • Update Site: Applies any changes made in a template to all derived pages in the site list.

  • Copy to Site: Allows you to copy the selected template to another defined site.

  • Locate in Site: Opens the Site list and highlights the selected template.

Managing Templates Using the Assets Panel

As described in the previous section, numerous options exist for managing templates in the Assets panel. We've covered topics such as refreshing the site list, re-creating the site cache, updating the current page, updating the site, copying to the site, and locating in the site as they relate to other aspects of development. In this section, I'll introduce you to alternatives for creating new templates, editing templates, opening a new page based on a template, and deleting templates straight from the Assets panel.

You can create a new blank template by choosing the New Template option from the Assets panel's Options menu. Doing this allows you to establish a new empty template and then edit it when you're ready. To do this, follow these steps:

1.

Select the New Template option from the Assets panel's Options menu. A New untitled template is created (see Figure 15.22).

Figure 15.22. A new untitled blank template is created in the template list.


2.

Enter a name for your new template and press Enter to apply the name.

3.

With the new template selected in the list, click the Edit icon (located second from the right in the icon bar). You can also press Enter with the template selected to open the template in Edit mode.

4.

Insert page elements and editable regions.

5.

Save your work.

Of course, you can delete a template by selecting it from the list and either pressing the Delete key on your keyboard or clicking the trash icon (located first from the right in the button bar). Note that Dreamweaver won't alert you of files that are tied to that template. After you delete a template, ties to that template are broken.

CAUTION

When you delete a template, not only are the ties to that template broken, but the DWT files is permanently deleted from the site.


Finally, you can create a template-derived page straight from the Assets panel, effectively saving you from the more tedious approach of choosing the New option from the File menu, locating the template, and clicking Create. To do this, right-click the template in the template list and choose the New from Template option from the context menu. Selecting this option opens an instance of the template in the Document window.

Applying Templates to Existing Pages

Dreamweaver makes it easy for you to apply various template designs to an existing document while at the same time maintaining your current content. When would this come in handy? Assume you were building various designs for a client in the hopes that they would choose the one they liked and then build their website based on the design they picked. Rather than designing numerous templates and then numerous template-derived pages for each of the templates, you could easily create one template with a set of editable regions and then a template-derived page that would represent the client-supplied content to add. If the client didn't like the original template, no problem, you can keep the content you already added to the template-derived page. You'd simply create other templates (with the same editable regions as the original) and apply the template to the existing template-derived page.

Numerous possibilities for this feature exist. A second example is an existing page updated seasonally. You could create four different templates that represent the four different seasons of the year. When you're ready to apply the appropriate seasonal template, open the template-derived page and choose the Apply Template feature. Let's describe this process with more detail:

1.

Reopen the template.dwt file for editing.

2.

Select the header.gif image and change its source to header_xmas.gif.

3.

Choose the Save As Template option from the File menu and save the template as template_xmas.dwt.

4.

Close the template.

5.

Now open the engineering.htm page by double-clicking to open it from the Files panel.

6.

Switch to the Templates category in the Assets panel.

7.

Select the template_xmas option from the template list.

8.

Click Apply.

As you can see from Figure 15.23, the Dorknozzle Christmas template is applied to the engineering page.

Figure 15.23. The Dorknozzle Christmas template is applied to the engineering page.


Because the editable regions in both the template and template_xmas pages coincide with those in the engineering.htm page, the transition is seamless. Of course, we can easily switch back to the regular template when we're ready. To demonstrate the switch back, let's use the Apply Template to Page method from the Modify menu:

1.

With the engineering.htm page still open, choose Modify, Templates, Apply Template to Page. The Select Template dialog appears.

2.

Choose the template you want to apply to the engineering.htm page from the templates list and click Select.

The original template is now applied.

Mapping Template Regions

When Dreamweaver applies a template to a page, it attempts to match the regions on the two pages with one another. If there is a one-to-one correspondence with the regions on the template page and the ones on the normal page, the transition happens smoothly. If the regions do not match, however (maybe you called an editable region in a new template NewHeading but that same region is called MyHeading in the page), Dreamweaver gives you the opportunity to line up the inconsistent region names using the Inconsistent Region Names dialog, shown in Figure 15.24.

Figure 15.24. The Inconsistent Region Names dialog allows you to remap inconsistent region names between two pages.


The Inconsistent Region Names dialog appears automatically when Dreamweaver finds regions that don't match between a template and a page for which the template is being applied. Dreamweaver will not let you proceed until all inconsistent regions have been addressed.

NOTE

The Inconsistent Region Names dialog is a way for Dreamweaver to map editable regions in a template to specific areas in a page. However, more often than not, Dreamweaver cannot map a specific area to a region, especially when that region doesn't exist. Because this is the case, you have the option of Ignoring a region: By choosing the Nowhere option from the Move Content to New Region menu, you can instruct Dreamweaver to disregard the mapping of a particular region.


To remap regions using the Inconsistent Region Names dialog, follow these steps:

1.

Open the engineering.htm page if it's not open already.

2.

Select the widgets template from the template list in the Assets panel.

3.

Click the Apply button. Because the regions on this template and the regions on the engineering.htm page are different, the Inconsistent Region Names dialog appears.

4.

Because the template and the page have completely different editable regions, choose the Nowhere option from the drop-down menu and click the Use for All button.

5.

Click OK when you're finished.

If there are regions you want to map from one page to the other, those regions appear in the drop-down menu. Rather than choosing the Nowhere option, you could instead select the region name to which you want to remap the inconsistent region.




Macromedia Dreamweaver 8 Unleashed
Macromedia Dreamweaver 8 Unleashed
ISBN: 0672327600
EAN: 2147483647
Year: 2005
Pages: 237
Authors: Zak Ruvalcaba

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