Understanding Template Parameters


Think of template parameters as page-based variables. Template parameters are established while editing a Dreamweaver template; each parameter or variable is given a default value when defined. When an optional region is defined, for example, the parameter is set to either true or false.

The code for template parameters is in the form of a specialized HTML comment; when inserted into a template, the code looks like this:

 <!-- TemplateParam name="inConclusionSection" type="boolean" value="false" --> 

The code is slightlybut significantlydifferent when a child page is generated from the template:

 <!-- InstanceParam name="inConclusionSection" type="boolean" value="false" --> 

The values of these and any other defined template parameters can be changed by a Dreamweaver or Contribute user while working on a child page derived from the template. For example, if the inConclusionSection optional region is enabled to be displayed in the Template Properties dialog box, the value in the code is altered like this:

 <!-- InstanceParam name="inConclusionSection" type="boolean" value="true" --> 

Template parameters are created automatically when you insert one of two different Dreamweaver template objects. As noted in Lesson 8, a template parameter is inserted in the <head> area whenever a basic optional region is created; advanced, dependent optional regions don't add another template parameter statement to the page. Template parameters are also written into the code whenever an editable attribute is defined. As you'll see later in this chapter, you can insert an editable attribute into any HTML tag not contained within an editable region.

Tip

It's often necessary to insert a template parameter manually in the <head> region of a document. For example, if you want to set up a template parameter to control the path to aserver-side include, you need to hand-code the parameter. A template expression, describedlater in this chapter, is then used to reference the template expression in the SSI tag.


The template parameter used to make an attribute editable might be one of a variety of types. Selecting the proper type is important because the type determines which controls are available for the entry in the Template Properties dialog box. A Boolean type of template parameter is displayed with a checkbox, for example. If you select a template parameter of the color type in the Template Properties dialog box, a color picker pop-up is presented. There are five different template parameter types to choose from:

  • Boolean. Used in conjunction with optional regions, Boolean template parameters accept either true or false as values. Note that Boolean template parameters are case sensitive; values such as true, False, trUE, and FALSE are not acceptable.

  • Color. Color template parameters accept standard color names (red, blue, green, and so on) and hexadecimal color values in either long form (#000000) or short form (#00).

  • Number. A number template parameter value can be positive or negative, integer or decimal, as long as it's within the double-precision floating-point range (64-bit). Some attributes that require numbers are width, height, and z-index, among others. A standard text field is displayed when a number template parameter is selected in the Template Properties dialog box.

  • Text. Any text string can be used as the value for a text template parameter. If special characters such as quotes are to be included in the parameter value, character entities must be used; either named character entities (&quot;) or numeric character entities (&#34;) are acceptable. The Template Properties dialog box provides a text field for changing the value of a text template parameter.

  • URL. URL template parameters are treated like standard links in a Dreamweaver page; that is, they're updated automatically if the referenced page changes location within the site or is renamed. You can use either absolute URLs (such as http://www.macromedia.com/images/logo.gif) or relative references (either document-relative, such as ../images/logo.gif; or site-relative, such as /images/logo.gif). If you select a URL template parameter in the Template Properties dialog box, both a text field and related folder icon (which opens a Select File dialog box) are displayed.

Each template parameter in the same template must have a unique name. When naming your template parameters, it's best to follow standard JavaScript naming conventions: Don't use spaces or other special characters, start the name with a letter rather than a number, and don't use JavaScript-reserved words as names.

Tip

Words reserved in JavaScript include abstract, else, instanceof, switch, boolean, enum, int, synchronized, break, export, interface, this, byte, extends, long, throw, case, false, native, throws, catch, final, new, transient, char, finally, null, true, class, float, package, try, const, for, private, typeof, continue, function, protected, var, debugger, goto, public, void, default, if, return, volatile, delete, implements, short, while, do, import, static, with, double, in, and super.




Design and Deploy Websites with Macromedia Dreamweaver MX 2004 and Contribute 3(c) Training from the Source
Design and Deploy Websites with Macromedia Dreamweaver MX 2004 and Contribute 3: Training from the Source
ISBN: 032128884X
EAN: 2147483647
Year: 2006
Pages: 130
Authors: Joseph Lowery

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net