In Dreamweaver 4.0, we have already been exposed to the concepts of templates and libraries, and know that they are good tools for batch generating web pages with similar styles. Now in Dreamweaver MX (hereinafter referred to as DW MX), the functions of templates and libraries have been further refined and strengthened, especially the feature of automatically updating associated web pages, making templates and libraries a highlight of DW MX.
1. First, let’s take a look at the application of templates. Different from Dreamweaver 4.0, DW MX expands the operation of templates to the two menus of “Modify” and “Insert”. At the same time, you can also create templates directly in the "Assert" sub-option of the "File" option.
2. Find the "Assert" sub-option and click the "Templates" button in the left toolbar. The template at this time is empty. We can click the "New Template" button in the lower right corner and a blank template will appear in the In the panel (as shown in Figure 1), click the template name to enter the editable state. Note that no elements have been added to the template at this time. We can add tables, images, text, etc. to the template just like editing ordinary web pages. After adding, save the template. You can find the template you just made in the "Templates" subfolder of the default site folder, with the extension .dwt.
If you find this troublesome, DW MX also provides a more direct method. After editing the web page to be saved as a template, click "Save as Templates" in the "File" menu to generate a template.
3. After the template is generated, editable areas must be established to prepare for filling in different web content in the future. Open the template, click the menu "Insert/Template Object/Editable Region", and the editable region dialog box will appear. After specifying the region name, you can see a blue box appearing in the template. After saving, the template of the editable area is created.
4. How to generate web pages in batches? Click the menu "File/New", select the "Templates" option, and you will immediately see the generated template. Click the "Create" button, and the template will start to be automatically applied to the web page. At this time we can see that the original template area is yellow and the elements in it are fixed and cannot be edited, while the editable area we just designated is blue and can be edited. In this way, it not only greatly simplifies our workload of generating similar web pages, but also effectively ensures the consistency of the web page style.
5. Finally, there is the batch update of associated web pages. This is an indispensable technology for large websites to update web pages, and it can be easily implemented in DW MX. Because all our web pages apply the same template, and these web pages are saved in the same site directory, when we want to make changes to the common elements of all web pages, we only need to modify the elements in the template.
Open the "Templates" sub-option and double-click the template of the associated web page. At this time, the template enters the editable state and the yellow area disappears. After changing the content of the template, a prompt dialog box will appear when saving: "The following web pages use the current template. , do you want to update?" (Figure 2) Click "Update", at this time, all associated web pages created based on the template will be updated (Figure 3).
Figure 2
Figure 3
Similar to templates, DW MX's library is more flexible. Click "Library" on the "Assert" tab to open the library. There are currently no elements in the library. We add the elements in the web page to generate the library, such as tables and images. , drag it directly to the library panel (as shown below).
Note that the elements in the library are never just the images or text themselves, but also the code that arranges those images in the web page. Therefore, we can also add the same library elements to the web page as in the template to mass-produce web pages with similar styles. At this time, we only need to drag the element back to the new web page in the library panel, and the relevant code will be automatically copied to the new web page.
Moreover, the library element can also realize batch updates of the website. We click the library element in the library panel to make the library enter editable state (as shown in Figure 5). When the library element is changed and saved, all those who use the library element The web page will be automatically updated simultaneously.
Figure 5
Finally, there is one more addition to automatic updates: If a web page is generated using a template, but you want to keep it as it is when it is automatically updated, and not update it with the rest of the site's web pages, just click "Modify/Templates/Detach from Templates", at this time, the webpage is no longer constrained by the template, and the webpage needs to be updated manually.