How to use templates in Dreamweaver (with code)

不言
Release: 2018-09-29 14:56:46
forward
8463 people have browsed it

The content of this article is about how to use templates in Dreamweaver (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

The functions of templates:

1. Helps to maintain a consistent appearance and style of the entire website;

2. After modifications are made in the template , all pages to which the template is applied will be updated automatically.

Simple example:

// In its .dwt template

<!-- TemplateBeginEditable name="myName" -->
    设置可编辑区域
<!-- TemplateEndEditable -->
Copy after login

// In the page , declare the address of the application template, and the area, etc.

<HTML>
<!-- InstanceBegin template="/Templates/myTemplates.dwt" codeOutsideHTMLIsLocked="false" -->
  <HEAD>
  </BODY>
<!-- InstanceEnd -->
</HTML>
Copy after login

// In the template area, set the editable area

<!-- InstanceBeginEditable name="myName" -->
    放入可编辑区域的内容
<!-- InstanceEndEditable -->
Copy after login


<HTML>
<HEAD>

<TITLE>TemplatesTITLE>


HEAD>
<BODY>

<TABLE border="0" align="center" cellspacing="0" cellpadding="0">
<TR>
<TD>

<TABLE border="0" cellspacing="0" cellpadding="0">
<TR>
            
<TD><img src="Temp_images/head_1.gif">TD>
            
<TD><img src="Temp_images/head_2.gif">TD>
            
<TD><img src="Temp_images/head_3.gif">TD>
        
TR>
        
TABLE>
    
TD>
TR>
<TR>
    
<TD>
    

    
<TABLE border="0" cellspacing="0" cellpadding="0">
    
<TR>
        
<TD valign="top">
        

        
<TABLE border="0" cellspacing="0" cellpadding="0">
        
<TR>
            
<TD><href="tempTest_00.html"><img src="Temp_images/left_1.gif" border="0">a>TD>
        
TR>
        
<TR>
            
<TD><href="tempTest_01.html"><img src="Temp_images/left_2.gif" border="0">a>TD>
        
TR>
        
<TR>
            
<TD><href="tempTest_02.html"><img src="Temp_images/left_3.gif" border="0">a>TD>
        
TR>
        
<TR>
            
<TD><href="tempTest_03.html"><img src="Temp_images/left_4.gif" border="0">a>TD>
        
TR>
        
<TR>
            
<TD><img src="Temp_images/left_5.gif">TD>
        
TR>
        
<TR>
            
<TD><img src="Temp_images/left_6.gif">TD>
        
TR>
        
<TR>
            
<TD><img src="Temp_images/left_7.gif">TD>
        
TR>
        
<TR>
            
<TD><img src="Temp_images/left_8.gif">TD>
TR>
                                            
#>            <TD
><img src="Temp_images/left_9.gif">
TD>                                                                                                                                            TR>
                                              
src="Temp_images/left_10.gif">TD
>                                                                                                                                                                            #TABLE>
                    ##TD>       <TD valign="top">

##
                                                                            ;!--
InstanceBeginEditable name="right"
-->                                                                            width
="450"
border="0"> <tr> <

td
height="50">
td >    <td width="450"> td>
    
<td > td>
  
tr>
  
<tr>
    
<td> td>
    
<td align="right"><br><br>
      
<h1>欢迎来到我的站点!h1>
      
<br><br><br><br><br><br><br><br>
          xugang
<br><br>
          2008.10.26
<br>
    
td>
    
<td> td>
  
tr>
  
<tr>
<td> td>
<td> td>
<td> td>
tr>
table>

TD>
TR>
TABLE>
TD>
TR>
TABLE>
BODY>

HTM

简单示例:

<HTML><!-- InstanceBegin template="/Templates/myTemplates.dwt" codeOutsideHTMLIsLocked="false" -->
<HEAD>
<!-- InstanceBeginEditable name="doctitle" -->
<TITLE>Templates</TITLE>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</HEAD>
<BODY>
<!-- 第一层表格  布局:2行1列-->
<TABLE border="0" align="center" cellspacing="0" cellpadding="0">
<TR>
    <TD>
        <!-- 第二层表格:页眉  布局:1行3列-->
        <TABLE border="0" cellspacing="0" cellpadding="0">
        <TR>
            <TD><img src="Temp_images/head_1.gif"></TD>
            <TD><img src="Temp_images/head_2.gif"></TD>
            <TD><img src="Temp_images/head_3.gif"></TD>
        </TR>
        </TABLE>
    </TD>
</TR>
<TR>
    <TD>
    <!-- 第二层表格:内容  布局:1行2列-->
    <TABLE border="0" cellspacing="0" cellpadding="0">
    <TR>
        <TD valign="top">
        <!-- 第三层表格:左边列表  布局:10行1列-->
        <TABLE border="0" cellspacing="0" cellpadding="0">
        <TR>
            <TD><a href="tempTest_00.html"><img src="Temp_images/left_1.gif" border="0"></a></TD>
        </TR>
        <TR>
            <TD><a href="tempTest_01.html"><img src="Temp_images/left_2.gif" border="0"></a></TD>
        </TR>
        <TR>
            <TD><a href="tempTest_02.html"><img src="Temp_images/left_3.gif" border="0"></a></TD>
        </TR>
        <TR>
            <TD><a href="tempTest_03.html"><img src="Temp_images/left_4.gif" border="0"></a></TD>
        </TR>
        <TR>
            <TD><img src="Temp_images/left_5.gif"></TD>
        </TR>
        <TR>
            <TD><img src="Temp_images/left_6.gif"></TD>
        </TR>
        <TR>
            <TD><img src="Temp_images/left_7.gif"></TD>
        </TR>
        <TR>
            <TD><img src="Temp_images/left_8.gif"></TD>
        </TR>
        <TR>
            <TD><img src="Temp_images/left_9.gif"></TD>
        </TR>
        <TR>
            <TD><img src="Temp_images/left_10.gif"></TD>
        </TR>
        </TABLE>
        </TD>
        <TD valign="top"> <!-- 右边内容向上对齐 -->

        <!-- 第三层表格:右边内容  布局:2行1列-->
        <!-- InstanceBeginEditable name="right" -->
               <table width="450" border="0">
  <tr>
    <td  height="50"> </td>
    <td width="450"> </td>
    <td > </td>
  </tr>
  <tr>
    <td> </td>
    <td align="right"><br><br>
      <h1>欢迎来到我的站点!</h1>
      <br><br><br><br><br><br><br><br>
          xugang    <br><br>
          2008.10.26<br>
    </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>

        <!-- InstanceEndEditable --></TD>
    </TR>
    </TABLE>
    </TD>
</TR>
</TABLE>
</BODY>
<!-- InstanceEnd -->
</HTML>
Copy after login

注意要点:

A  在创建模板时,必须慎重定义可编辑区域和不可编辑区域。

B  模板将自动保存在“Templates”文件夹中,该文件夹在站点的本地根文件夹下。

1. 不能模板从“Templates”文件夹中移出;

2. 不能将非模板文件放在“Templates”文件夹中;

3. 不能将“Templates”文件夹从站点的本地根文件夹中移出。

将现有文件保存为模板:

1.打开要转变成模板的页面;

2.选择“文件”->“另存为模板”,保存模板;

新建空白模板:

1.选择“窗口”->“资源”命令(或按 F11键)。

2.单击“资源”面板上的“模板”图标,显示“模板”面板。

3.单击“模板”面板右下角的“新建模板”图标。

默认情况下,整个模板都处于锁定状态。

添加可编辑区域:

方法一:

在“插入”栏->“常用”选项卡->“模板”图标->“可编辑区域”;

方法二:

在“插入”->“模板对象”->“可编辑区域”;

方法三:

按Ctrl+Alt+V 组合键;

方法四:

右键选中区域->“模板”->“新建可编辑区域”

删除可编辑区域:

选中编辑区域,“修改”->“模板”->“删除模板标记”,该区域将被锁定,不可编辑。

修改编辑模板:

Select "Window"->"Resources"->"Template" icon->Select the template you want to edit, and then double-click it. The template will appear in the "Document" window, and you can edit the template at this time.

Apply a template to a web page:

1. Open the document (ie: page) to which you want to apply the template;

2. Select "Window" -> "Resources" - >"Template" icon->Select the template you want to apply;

3. Drag the template from the panel into the page window (or click the "Apply" button);

4. Add or write data in the editable area;

Note:If there is already content in the document, the existing content must be moved to the editable area of ​​the template, otherwise Dreamweaver will delete it content!

The above is the detailed content of How to use templates in Dreamweaver (with code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!