Templates | Page Layout | Search Engines | Missing Pages | Style | Browser Screenshots
Much of the look and feel of the site is controlled through the use of Dreamweaver's templates. Templates have the following look:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <!-- TemplateParam name="TitleParam" type="text" value="Sample Title" --> <title>@@(TitleParam)@@</title>@@(TitleParam)@@ </head> <body> <h1>A Sample Title</h1> <!-- TemplateBeginEditable name="Article" --> <h2>Sample Content</h2> <p>More sample content.</p> <!-- TemplateEndEditable --> </body> </html>
The template syntax takes the form of HTML comments. Template parameters are created using the
TemplateParam comment with a name, a type (which can be
number) and the value the template parameter should have. Template parameters are ideal for attribute values or short plain text elements. They are poorly suited to situations where you wish to insert nested tag content. To insert the value of a parameter into a particular point in your document use the
@@(TemplateParamName)@@ syntax. These expressions are not limited to just printing out parameters values - they can be used to do basic arithmetic, string concatenation, execute conditionals and so on. Be warned, these expressions do not allow for assignment so intermediary values cannot be saved for later. Areas within editable regions will appear by default in things that inherit from the template but can be deleted away and changed. Consequently changing the contents of these editable regions in the template will not change the values of anything that might be inheriting from the template.
It is possible for templates templates to be nested (so one template can inherit from an earlier template) which provides an easy route to make a group or section of pages to share identical elements. However, template parameters of parent templates are expected to be filled in by child templates unless the
passthrough attribute is set to true. This passes responsibility for the value on to what ever inherits the given template. Additionally, while it is not possible to change any part of the page which was not editable in parent templates, it is possible to create new or redefine existing editable regions within existing editable areas. Only the innermost editable regions will be available for changing in any thing that inherits from the given template.
Pages can inherit from templates and only (by default) those areas above and below the template along with those parts of a template that were marked as editable can be changed. Any page that inherits from a template is then expected to fill in all remaining template parameters. However pages cannot create template parameters of their own - only set existing ones.
When modifying the code of pages that use templates some care must be taken. While Dreamweaver will not allow you to modify parts which are inherited from other templates other editors are not so careful.
A page may use a Template Parameters to take input and run it through an expression at a later point. If a Template Parameter is changed by any means other than the Template Properties window any template expressions within the page will not be re-evaluated and thus will not change. To overcome this, use the menu item Modify > Templates > Update Current Page to force an explicit re-evaluation.
To reach the Template Properties window use the Modify > Template Properties... menu item. The resultant window will restrict you to only those modifications that match the type of the parameters being changed. After OK is pressed all expressions on the page are re-evaluated.