Learn how to create nested templates to control content in pages that share design elements in Dreamweaver.

A nested template is a template whose design and editable regions are based on another template. Nested templates are useful for controlling content in pages of a site that share many design elements, but have a few variations between pages. For example, a base template might contain broader design areas and be usable by many content contributors for a site, while a nested template might further define the editable regions in pages for a specific section in a site.

Editable regions in a base template are passed through to the nested template, and remain editable in pages created from a nested template unless new template regions are inserted in these regions.

Changes to a base template are automatically updated in templates based on the base template, and in all template-based documents that are based on the main and nested templates.

In the following example, the template trioHome contains three editable regions, named Body, NavBar, and Footer:

A template with three editable regions
A template with three editable regions

To create a nested template, a new document based on the template was created and then saved as a template and named TrioNested. In the nested template, two editable regions have been added in the editable region named Body.

Nested template
Nested template

When you add a new editable region in an editable region passed through to the nested template, the highlighting color of the editable region changes to orange. Content you add outside the editable region, such as the graphic in the editableColumn, is no longer editable in documents based on the nested template. The blue highlighted editable areas, whether added in the nested template or passed through from the base template, remain editable in documents that are based on the nested template. Template regions that do not contain an editable region pass through to template‑based documents as editable regions.

Create a nested template

Nested templates let you create variations of a base template. You can nest multiple templates to define increasingly specific layouts.

By default, all editable template regions from the base template pass through the nested template to the document based on the nested template. That means that if you create an editable region in a base template, then create a nested template, the editable region appears in documents based on the nested template (if you did not insert any new template regions in that region in the nested template).

Бележка:

You can insert template markup inside an editable region so that it won’t pass through as an editable region in documents based on the nested template. Such regions have an orange border instead of a blue border.

  1. Create a document from the template in which you want to base the nested template. Do one of the following:

    • From the Assets panel, click Templates from the left pane. Select New Template from the bottom pane.

    • Select File > New. In the New Document dialog box, select the Page from Template category, then select the site that contains the template you want to use. In the Template list, double-click the template to create a new document.

  2. Select File > Save As. In the Save as dialog box, select Template Files in the Save as type drop-down list.

  3. Enter a name in the Save As box and click OK to save the new document as a nested template.

Prevent an editable region from passing through to a nested template

In nested templates, pass-through editable regions have a blue border. You can insert template markup inside an editable region so that it won’t pass through as an editable region in documents based on the nested template. Such regions have an orange border instead of a blue border.

  1. In Code view, locate the editable region you want to prevent from passing through.

    Editable regions are defined by template comment tags.

  2. Add the following code to the editable region code:
    @@(" ")@@

    This template code can be placed anywhere within the <!-- InstanceBeginEditable --><!-- InstanceEndEditable --> tags that surround the editable region. For example:

    <!-- InstanceBeginEditable name="EditRegion1" --> 
    <p>@@("")@@ Editable 1 </p> 
    <!-- InstanceEndEditable -->

Този материал е лицензиран под лиценз Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported  Публикациите в Twitter™ и Facebook не попадат под клаузите на Creative Commons.

Правни бележки   |   Правила за онлайн поверителност