Section 17.7. Updating a Template

17.7. Updating a Template

Templates aren't just useful for building pages rapidly ; they also make quick work of site updates. Pages created from templates maintain a link to the original template file; you can automatically pass changes to a template along to every page built from it. If you used templates to build your site, you probably won't cry on your keyboard when the boss says you must add an additional button and link to the navigation bar. Instead of editing every page, you can simply open the template file, update the navigation bar, and let Dreamweaver apply the update to all the pages.

You update a template (and all the pages based on it) like this:

  1. Choose Window Assets .

    The Assets panel appears.

  2. Click the Templates button (see Figure 17-4) .

    A list of the site's templates appears.

  3. Double-click the template's name to open it .

    Alternatively, you can select the template in the Assets panel, and then click the Edit button to open the original template (.dwt) file (see Figure 17-4).

    The template opens.


    Tip: You can also open a template by double-clicking the appropriate template (.dwt) file located in the Templates folder in the Files panel.
  4. Edit the template as you would any Web page .

    Since this is the original template file, you can edit any of the HTML in the document, including Cascading Style Sheets, meta tags, and layers . You can also add or remove editable regions (see Section 17.3).

    Take care, however, to edit only the areas that you did not mark as editable regions. The reason: When you update your pages, any region marked as editable in a template file isn't passed on to pages based on that template. After all, the template is supposed to dictate only the design of those pages' non -editable regions.


    Note: Be careful when you remove editable regions from a template. If you've already built some pages based on the template, Dreamweaver warns you when you save the template. As described below, you can either delete the content that was added to that region in each of the pages you created, or move it to another editable region in the page.
  5. Choose File Save .

    If you've already created pages based on this template, Dreamweaver opens the Update Template Files dialog box. It lists all the files that use the template.

  6. Click Update to update all files based on the template .

    Dreamweaver automatically applies the changes you made to the pages based on the template. Then, the Update Pages dialog box opens. If you want to see a list of all files Dreamweaver changed while updating your site, turn on the "Show log" box.

    On a large site, this automatic update feature can be an incredible time-saver, but you may not want to click Update, at least not right now. Perhaps you're just saving some of your hard work on the template but aren't quite finished perfecting itwhy waste your time updating all those pages more than once? In such a scenario, click the Don't Update button. Remember, you can always update the pages later (see the box on Section 17.7.2).

  7. Click Close .

    The Update Pages dialog box closes .

You need to update all your files even if you make a simple change to the template, like changing its name.

17.7.1. Updating Nested Templates

When you build a Web site using nested templates, you have multiple templates affecting your pages. The master template controls design elements of a nested template, which in turn controls pages based on the nested template. (You can even make nested templates out of nested templates, but for sanity 's sake, you'd better not.) With this level of complexity, updates to nested templates can get confusing fast.

In a nutshell , here's how it works:

  • If you edit a locked region in a master template and then update your site, not only does a nested template update, but so do all pages built from it.

  • If you edit a locked region in a nested template and then update, those changes pass on to pages built from that nested template.

However, changes you make to an editable region of a master template don't pass on to any page. Neither do changes you make in editable regions of a nested template.


Note: Sometimes after making changes to a master template, Dreamweaver doesn't update pages based on nested templates. The surefire way to verify that all template updates are correctly done is to first recreate the Site Cache (Site Advanced Recreate Site Cache), choose Modify Templates Update Pages, and then select the "Entire Site option.
POWER USERS' CLINIC
Wait to Update

Whenever you modify and save a Library item or a template, Dreamweaver gives you the option of updating any pages in the site that are descended from it. Very often, you'll say Yes.

But there are times when you'll want to wait to update the site. If you're making a lot of changes to multiple Library items or templates, for example, you may wish to wait until you've finished all your edits before letting the changes ripple through your pages. After all, it can take some time to update large sites with lots of pages.

Dreamweaver lets you update pages that use Library items and templates at any time. Just choose Modify Library Update Pages, or Modify Templates Update Pages. Both menu options open the same dialog box, as shown here.

At this point, you can update pages that use a specific Library item or template by choosing "Files that Use" from the "Look in" menu and then selecting the appropriate name from the pop-up menu. If you would like to update all pages in the site, choose Entire Site, and then select the name of the local site from the pop-up menu. Turn on both the "Library items" and Templates checkboxes to update all pages.

To see the results of Dreamweaver's work, check the "Show log" box. This presents a list of all files Dreamweaver changed as it updated the site.


17.7.2. Unlinking a Page from a Template

If you're confident that you won't be making any further changes to a page's template, and you'd like to be able to edit the page's locked regions, you can break the link between a page and its template choosing Modify Templates Detach from Template.

All the HTML in the page is now editable, just as on a regular Web pagewhich is what it is now. You've removed all references to the original template, so changes to the template will no longer have any effect on this page.


Note: If you unlink a nested template from its master template, Dreamweaver removes only the code provided by the original master template. Any editable regions you added to the nested template remain .

17.7.3. Exporting a Template-Based Site

The good news about Dreamweaver's sophisticated templating features is that they let you build complex Web pages that are easy to create and update. The bad news is that some behind-the-scenes code is necessary to achieve this ease of use. Dreamweaver's template features rely on HTML comment tags to identify editable, optional, and repeating regions, as well as nested template and editable tag attributes (see the box on Section 17.3.1). Although this code is only for Dreamweaver's use and has no effect on how a Web browser displays the page, it does add a small amount to the size of your Web pages.

Fortunately, Dreamweaver includes a feature that lets you export an entire site into a new folder on your computer without any template markup code. It's a good last step before transferring a freshly completed Web site to a Web server.

  1. Choose Modify Templates Export Without Markup .

    Dreamweaver uses the currently active site, so make sure you've got the site you wish to export selected in the Files panel (see Section 13.1.5). The Export Site Without Template Markup window appears (see Figure 17-19).

    Figure 17-19. Dreamweaver lets you strip out template code from template-based pages with the Export Site Without Template Markup command.
  2. Click the Browse button and select a folder for the exported site .

    Select a folder other than the current local site folder. You always want to keep the original files in the local folder, since they're the ones that keep the template markup, making future updates possible.

  3. Turn on the export options you want .

    The Export window includes two options. The first, "Keep template data files," creates an XML file for each template-based page. In other words, when you export the site, there's one HTML page (without any special template code) and an XML file (which includes all the template code as well as the page content).

    Theoretically, you could then go back and choose the File Import XML into Template to recreate the page, complete with the original template information. However, in practice, you probably wont. For one thing, this process creates lots of additional files that you wouldn't want to move to the Web site. Also, when you want to work on the site to update and edit it, you should use the original files in the site's local folder anyway, since they still have the useful template code in them.

    The "Extract only changed files" option speeds up the process of exporting a large template-based site. This option forces Dreamweaver to export only pages that you've changed since the last export. Unfortunately, it doesn't tell you which files it exported until after the fact. So, to make sure you get those newly exported files to the Web server, you need to keep track of changes by hand.

  4. Click OK to export the site .

    Dreamweaver goes through each page of the site, stripping out template code and exporting it to the folder you specified.

It's a fine idea to perform an export after you've completed your Web site and are ready to move it to the Internet. You can then move the lean, clean exported files to the Web server.

You can use Dreamweaver's FTP feature to do the uploading (see Section 15.2), but you need to create a new site and define the folder with the exported files as a local root folder. Whenever you need to add or update template-based pages, use the original site files, and then export the changed files. You can then switch to the site containing the exported files and transfer the new or updated files to the Web server.



Dreamweaver 8[c] The Missing Manual
Dreamweaver 8[c] The Missing Manual
ISBN: 596100566
EAN: N/A
Year: 2006
Pages: 233

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