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:
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. |