About Dreamweaver templates
- Dreamweaver User Guide
- Dreamweaver and Creative Cloud
- Dreamweaver workspaces and views
- Set up sites
- About Dreamweaver sites
- Set up a local version of your site
- Connect to a publishing server
- Set up a testing server
- Import and export Dreamweaver site settings
- Bring existing websites from a remote server to your local site root
- Accessibility features in Dreamweaver
- Advanced settings
- Set site preferences for transferring files
- Specify proxy server settings in Dreamweaver
- Synchronize Dreamweaver settings with Creative Cloud
- Using Git in Dreamweaver
- Manage files
- Create and open files
- Manage files and folders
- Getting and putting files to and from your server
- Check in and check out files
- Synchronize files
- Compare files for differences
- Cloak files and folders in your Dreamweaver site
- Enable Design Notes for Dreamweaver sites
- Preventing potential Gatekeeper exploit
- Layout and design
- Understand Cascading Style Sheets
- Laying out pages using CSS Designer
- Using CSS preprocessors in Dreamweaver
- How to set CSS Style preferences in Dreamweaver
- Move CSS rules in Dreamweaver
- Convert inline CSS to a CSS rule in Dreamweaver
- Work with div tags
- Apply gradients to background
- Create and edit CSS3 transition effects in Dreamweaver
- Format code
- Page content and assets
- Set page properties
- Set CSS heading properties and CSS link properties
- Work with text
- Find and replace text, tags, and attributes
- DOM panel
- Edit in Live View
- Encoding documents in Dreamweaver
- Select and view elements in the Document window
- Set text properties in the Property inspector
- Spell check a web page
- Using horizontal rules in Dreamweaver
- Add and modify font combinations in Dreamweaver
- Work with assets
- Insert and update dates in Dreamweaver
- Create and manage favorite assets in Dreamweaver
- Insert and edit images in Dreamweaver
- Add media objects
- Adding videos in Dreamweaver
- Insert HTML5 video
- Insert SWF files
- Add audio effects
- Insert HTML5 audio in Dreamweaver
- Work with library items
- Using Arabic and Hebrew text in Dreamweaver
- Linking and navigation
- jQuery widgets and effects
- Coding websites
- About coding in Dreamweaver
- Coding environment in Dreamweaver
- Set coding preferences
- Customize code coloring
- Write and edit code
- Code hinting and code completion
- Collapse and expand code
- Reuse code with snippets
- Lint code
- Optimize code
- Edit code in Design view
- Work with head content for pages
- Insert server-side includes in Dreamweaver
- Using tag libraries in Dreamweaver
- Importing custom tags into Dreamweaver
- About XML and XSLT
- Perform server-side XSL transformations in Dreamweaver
- Performing client-side XSL transformations in Dreamweaver
- Add character entities for XSLT in Dreamweaver
- Format code
- Cross-product workflows
- Installing and using extensions to Dreamweaver
- In-App updates in Dreamweaver
- Insert Microsoft Office documents in Dreamweaver (Windows only)
- Working with Fireworks and Dreamweaver
- Edit content in Dreamweaver sites using Contribute
- Dreamweaver-Business Catalyst integration
- Create personalized email campaigns
- About Dreamweaver templates
- Recognizing templates and template-based documents
- Create a Dreamweaver template
- Create editable regions in templates
- Create repeating regions and tables in Dreamweaver
- Use optional regions in templates
- Define editable tag attributes in Dreamweaver
- How to create nested templates in Dreamweaver
- Edit, update, and delete templates
- Export and import xml content in Dreamweaver
- Apply or remove a template from an existing document
- Edit content in Dreamweaver templates
- Syntax rules for template tags in Dreamweaver
- Set highlighting preferences for template regions
- Benefits of using templates in Dreamweaver
- Mobile and multiscreen
- Dynamic sites, pages and web forms
- Understand web applications
- Set up your computer for application development
- Troubleshoot database connections
- Removing connection scripts in Dreamweaver
- Design dynamic pages
- Dynamic content sources overview
- Define sources of dynamic content
- Add dynamic content to pages
- Changing dynamic content in Dreamweaver
- Display database records
- Provide and troubleshoot live data in Dreamweaver
- Add custom server behaviors in Dreamweaver
- Building forms using Dreamweaver
- Use forms to collect information from users
- Create and enable ColdFusion forms in Dreamweaver
- Create web forms
- Enhanced HTML5 support for form elements
- Develop a form using Dreamweaver
- Building applications visually
- Build master and detail pages in Dreamweaver
- Build search and results pages
- Build a record insert page
- Build an update record page in Dreamweaver
- Building record delete pages in Dreamweaver
- Use ASP commands to modify database in Dreamweaver
- Build a registration page
- Build a login page
- Build a page that only authorized users can access
- Securing folders in Coldfusion using Dreamweaver
- Using ColdFusion components in Dreamweaver
- Test, preview, and publish websites
Learn how to use Dreamweaver templates to design a “fixed” page layout and then create documents based on the template that inherit its page layout.
A template is a special type of document that you use to design a “fixed” page layout; you can then create documents based on the template that inherit its page layout. As you design a template, you specify as “editable” which content users can edit in a document based on that template. Templates enable template authors to control which page elements template users—such as writers, graphic artists, or other web developers—can edit. There are several types of template regions the template author can include in a document.
Templates enable you to control a large design area and reuse complete layouts. If you want to reuse individual design elements, such as a site’s copyright information or a logo, create library items.
Using templates enables you to update multiple pages at once. A document that is created from a template remains connected to that template (unless you detach the document later). You can modify a template and immediately update the design in all documents based on it.
Templates in Dreamweaver differ from templates in some other Adobe Creative Cloud software in that page sections of Dreamweaver templates are fixed (or uneditable) by default.
Types of template regions
When you save a document as a template, most regions of a document are locked. As a template author, you specify which regions of a template-based document will be editable by inserting editable regions or editable parameters in the template.
As you create the template, you can make changes to both editable and locked regions. In a document based on the template, however, a template user can make changes only in the editable regions; the locked regions can’t be modified.
There are four types of template regions:
An editable region: An unlocked region in a template-based document—a section a template user can edit. A template author can specify any area of a template as editable. For a template to be effective, it should contain at least one editable region; otherwise, pages based on the template can’t be edited. For detailed information in editable regions, see Create editable regions in templates.
A repeating region: A section of the document layout that is set so that the template user can add or delete copies of the repeating region in a document based on the template as necessary. For example, you can set a table row to repeat. Repeating sections are editable so that the template user can edit the content in the repeating element, while the design itself is under the control of the template author.
There are two types of repeating regions you can insert in a template: repeating region and repeating table. To know how to work with repeating regions, see Create repeating regions and tables in Dreamweaver.
An optional region: A section of a template that holds content—such as text or an image—that may or may not appear in a document. In the template-based page, the template user usually controls whether the content is displayed. See the Optional region section for more information.
An editable tag attribute: Lets you unlock a tag attribute in a template, so the attribute can be edited in a template-based page. For example, you can “lock” which image appears in the document but let the template user set the alignment to left, right, or center. See Define editable tag attributes in Dreamweaver for more information.
Links in templates
When you create a template file by saving an existing page as a template, the new template in the Templates folder, and any links in the file are updated so that their document-relative paths are correct. Later, when you create a document based on that template and save it, all the document-relative links are updated again to continue to point to the correct files.
When you add a new document-relative link to a template file, it’s easy to enter the wrong path name if you type the path into the link text box in the Property inspector. The correct path in a template file is the path from the Templates folder to the linked document, not the path from the template-based document’s folder to the linked document. Ensure that the correct paths for links exist by using either the folder icon or the Point-to-file icon in the Property inspector when creating links in templates.
Server scripts in templates and template-based documents
Some server scripts are inserted at the very beginning or end of the document (before the <html> tag or after the </html> tag). Such scripts require special treatment in templates and template-based documents. Normally, if you make changes to script code before the <html> tag or after the </html> tag in a template, the changes are not copied to documents based on that template. This can cause server errors if other server scripts, within the main body of the template, depended on the scripts that are not copied. An alert warns you if you change scripts before the <html> tag or after the </html> tag in a template.
To avoid this problem, you can insert the following code in the head section of the template:
<!-- TemplateInfo codeOutsideHTMLIsLocked="true" -->
When this code is in a template, changes to scripts before the <html> tag or after the </html> tag are copied to documents based on that template. However, you will no longer be able to edit those scripts in documents based on the template. Thus, you can choose to either edit these scripts in the template, or in documents based on the template, but not both.
Template parameters indicate values for controlling content in documents based on a template. Use template parameters for optional regions or editable tag attributes, or to set values you want to pass to an attached document. For each parameter, you select a name, a data type, and a default value. Each parameter must have a unique name that is case sensitive. They must be one of five permitted data types: text, boolean, color, URL, or number.
Template parameters are passed to the document as instance parameters. In most cases, a template user can edit the parameter’s default value to customize what appears in a template-based document. In other cases, the template author might determine what appears in the document, based on the value of a template expression.
Template expressions are statements that compute or evaluate a value.
You can use an expression to store a value and display it in a document. For example, an expression can be as simple as the value of a parameter, such as @@(Param)@@, or complex enough to compute values which alternate the background color in a table row, such as @@((_index & 1) ? red : blue)@@.
You can also define expressions for if and multiple-if conditions. When an expression is used in a conditional statement, Dreamweaver evaluates it as true or false. If the condition is true, the optional region appears in the template-based document; if it is false, it doesn’t appear.
You can define expressions in Code view or in the Optional Region dialog box when you insert an optional region.
In Code view, there are two ways to define template expressions: use the <!-- TemplateExpr expr="your expresson"--> comment or @@(your expression)@@. When you insert the expression in the template code, an expression marker appears in Design view. When you apply the template, Dreamweaver evaluates the expression and displays the value in the template-based document.
Template expression language
The following features and operators are supported:
numeric literals, string literals (double-quote syntax only), Boolean literals (true or false)
variable reference (see the list of defined variables later in this section)
field reference (the “dot” operator)
unary operators: +, -, ~, !
binary operators: +, -, *, /, %, &, |, ^, &&, ||, <, <=, >, >=, ==, !=, <<, >>
conditional operator: ?:
The only objects available are those defined by the expression object model. The following variables are defined:
Contains the document-level template data with a field for each parameter in the template.
Only defined for expressions which appear inside a repeating region. Provides built‑in information about the region
The numerical index (from 0) of the current entry
The total number of entries in this repeating region
True if the current entry is the first entry in its repeating region
True if the current entry is the last entry in its repeating region
The _repeat object for the previous entry. It is an error to access this property for the first entry in the region.
The _repeat object for the next entry. It is an error to access this property for the last entry in the region.
In a nested repeated region, this gives the _repeat object for the enclosing (outer) repeated region. It is an error to access this property outside of a nested repeated region.
During expression evaluation, all fields of the _document object and _repeat object are implicitly available. For example, you can enter title instead of _document.title to access the document’s title parameter.
In cases where there is a field conflict, fields of the _repeat object take precedence over fields of the _document object. Therefore, you shouldn’t need to explicitly reference _document or _repeat except that _document might be needed inside a repeating region to reference document parameters that are hidden by repeated region parameters.
When nested repeated regions are used, only fields of the innermost repeated regions are available implicitly. Outer regions must be explicitly referenced using _parent.
Multiple If condition in template code
You can define template expressions for if and multiple-if conditions. This example demonstrates defining a parameter named "Dept", setting an initial value, and defining a multiple-if condition which determines which logo to display.
The following is an example of the code you might enter in the head section of the template:
<!-- TemplateParam name="Dept" type="number" value="1" -->
The following condition statement checks the value assigned to the Dept parameter. When the condition is true or matches, the appropriate image is displayed.
<!-- TemplateBeginMultipleIf --> <!-- checks value of Dept and shows appropriate image--> <!-- TemplateBeginIfClause cond="Dept == 1" --> <img src=".../sales.gif"> <!-- TemplateEndIfClause --> <!-- TemplateBeginIfClause cond="Dept == 2" --> <img src=".../support.gif"> <!-- TemplateEndIfClause--> <!-- TemplateBeginIfClause cond="Dept == 3" --> <img src=".../hr.gif"> <!-- TemplateEndIfClause --> <!-- TemplateBeginIfClause cond="Dept != 3" --> <img src=".../spacer.gif"> <!-- TemplateEndIfClause --> <!-- TemplateEndMultipleIf -->
When you create a template-based document, the template parameters are automatically passed to it. The template user determines which image to display.