Current location - Plastic Surgery and Aesthetics Network - Wedding supplies - How to add a template in dreamweaver
How to add a template in dreamweaver
1. Edit Page

Open DW and create a new site, which we call "Spider Web".

Create a new blank page as an inner page (usually a website has only one home page, so we don't need to make a template for the home page) and name it body.htm.

Edit this page and finish as shown in figure 1.

Figure 1, edited body.htm page. Note point A, which will be used as an editable area, which will be mentioned below.

2. Generate a template

After editing, we saved this page as a template (note that it is not saved as an ordinary htm page). Save Fileà as template in DW can be saved as template. After executing this command, the Save As Template window will pop up, as shown in Figure 2.

Figure 2, save as template window.

In Figure 2, the site is selected at B, we select "Spider Web", at C, we select the file name of the template we want to save as, and we fill in the main body. Click Save in the upper right corner to save.

At this time, we press F8 to bring up the site (site manager), and we can see the body.dwt in the Templates folder (when there is a template file, DW will automatically generate the Templates folder, and dwt is a template type file).

3. Edit the template

When you open the body.dwt template file in Site, you will find that it looks no different from the body.dwt page, but it is actually different. Cannot add editable region in body.htm. Editable areas can only be added to template files.

In order to make people understand "editable region" better, let's first generate an htm file with this template: click FileàNew From Template to pop up the window of Selecting template, select body in emplates, and then click Select in the upper right corner to generate a new htm file. We renamed this new page body2.htm. Now we use DW to open files in body.htm and body2.htm, and compare their differences. You will find the words "Template: Text" written in the upper right corner of body2.htm page. (This page is generated by the body.dwt template file) At the same time, you will be surprised to find that the body2.htm file cannot be edited (body.dwt can be edited). By the way, this is the result that the generated page cannot be edited because "editable region" is not defined in the body.dwt template file. Therefore, we must add an editable region to the template file. Here are the steps to add an editable region:

1) Open the body.dwt template file, and we hope that the intermediate table can be edited (that is, point A in the figure 1). But in the body.dwt file, not in the body.htm), so you need to add an editable region here.

2) Place the mouse cursor at a place in the table, click the right mouse button, and select New Editable Area …, and the window of New Editable Area will pop up, asking for the name of this editable area (we usually call it Editable Area Label). We fill in Region0 1, click OK to close the window and finish editing the labels of the currently editable regions. At this point, you can see a display in the table as shown in Figure 3.

Figure 3, the new editable region window.

It means that there is an editable region marked as Region0 1.

So far, we have defined an editable region. If there are multiple editing areas, we can do the same.

You can also create a new editable region by modifying the template. ※. If you want to delete an editable region, you can modify the template to remove the editable region ... and then follow the prompts.

4. Use templates to generate pages

In fact, we also mentioned the step of generating pages with templates, that is, through FileàNew From Template. Please refer to the relevant steps in the third step. Now we use this template to generate a page named body3.htm. At this time, you will find that in the body3.htm page, except for the editable region Region0 1, the mouse is restricted. We add what we need in this editable area, such as writing an article casually. In this way, we can use templates to generate pages according to our own needs.

5. Modify the template content and update the website file.

Open the body.dwt template file and modify what we need to modify. For example, we change the logo image or modify any non-editable areas, and even add or delete editable areas.

Here's how the template updates the file by changing the logo.

We change the logo image to another image we like, and save the body.dwt file when it is finished. At this time, DW will pop up a window asking if it is necessary to update the file. Select Update, and DW will automatically update all pages generated by this template. When updating, DW will pop up the update page window, and the update log will be given in the update page window after completion.

If you choose not to update, DW will keep the template file directly, and will not update the page for the time being, but we can update the page manually, just choose to modify the template update page. ※

At this point, we open any page generated by body.dwt, such as body3.htm. You will find that the logo picture has changed.

It is not difficult to find that with this function, we can easily solve the problem of website update. Templates have a very powerful function. This article only plays a role in attracting jade. Many functions are not mentioned because of space problems, so we should try more to fully appreciate DW's template style.

In DW, there is another function called library, which can cooperate with the template organically and make the template more powerful. If readers are interested, I'd like to give you this gift.