Logo

Home | Audio | DIY | Guitar | iPods | Music | Brain/Problem Solving | Links| Site Map

This work is licensed under a Creative Commons License.

Template Parameters

As discussed above, you can think of template parameters as page variables that are user configurable and that you can reference anywhere in the template as long as the reference is not contained within an editable region. There are five different types of parameters, described in the list below. You must set the parameter with a default value in the template, and you can customize that value on each child page based on that same template. In other words, you might define a text type parameter named myname in the template equal to Brad (where "Brad" is the default value). Any page you make from the template (page1) will use the default value until you change it for that page. You can easily change it on the generated page (page1) to Murray with a couple of mouse clicks (discussed below).

Parameter Requirements

Parameter Format for the Template

The following is an example of parameter format based on the template.

 < !-- TemplateParam name="" type="" value="" -->

Note: Do not leave the following parameters as null strings: name, type, and value.

Parameter format for the Child Page

The following is an example of parameter format in achild page based on the template.

 < !-- InstanceParam name="" type="" value="" -->

Note: Do not leave the followingparameters as null strings: name, type, and value.

Here are some sample parameters and values for each type of template parameter.

Parameter Samples
Parameter Type Permitted Values
boolean false
boolean true
color #666
color #666666
color Blue
number 123456.00
number -123456.00
text Anything you want here, even entity encoded characters and punctuationare acceptable.
URL ../images/myimage.gif
URL /images/myimage.gif
URL http://www.mydomain.com/images/myimage.gif
URL mypage.htm

If your parameter value contains a double quote (") character, then you must entity encode the double quote or else the template engine will either throw an error (in most cases), or it will not display all the parameter data when you reference it through an expression. This is because the double quote character is a string identifier. Find below some common entity encoding conversions for the double quote below.

Common Conversions
Character Character Code/Entity
" &#34; or &quot;

Caution: When using the URL parameter type, forget what you know about the Dreamweaver asset management engine, and reference these parameter type values as if you were making the association in the child of the template. In other words, instead of referencing an image (from a file in the templates folder) as ../images/myimage.gif, you would reference it as if you were in the parent folder already, such as images/myimage.gif.

Caution: If you move an asset, such as moving an image to another folder location, or renaming the referenced asset, Dreamweaver somewhat manages the value of the URL type parameters. But only does so in the child pages of the template; and not in the template.

Caution: When using the boolean parameter type, the value must be a lowercase true or false as the template engine does not accept an uppercase True/False or TRUE/FALSE. Using any uppercase in the boolean value will result in an error message when you try to save the template.

Using Parameters in the Template

Template parameters, which are similar to JavaScript variables, do not displayvalues on the child page. In other words, simply creating a parameteron a page will have no effect on the page. To display thevalue of the parameter or use it in calculations, you must referencethat template parameter in the template using a template expression.Read on for more information.

Passthrough Parameters

Our discussion of parameters wouldn't be complete ifwe didn't discuss these little critters. Think of passthrough parametersas a way to tell Dreamweaver MX to ignore the expression and to passits value and exposure through to the next 'generation' of pages.

Caution: You cannot use passthrough parameters on root level templates. You can use them in any nested template without incident.

Parameter Format - Template

Here is an example of the syntax for passthrough parameters.

 < !-- InstanceParam name="" type="" value="" passthrough="true" -->@@@(ParamName)@@@ 

Parameter Format - Child page

Nothing displays in code view. Simply put, passthrough parameters only relate to nested templates. In effect, they enable you to specify that the parameter cannot be customized on the second generation templates child page, but they will continue to be customizable on any third generation template's child pages. Our book, Dreamweaver MX Templates, covers this from pages 114 to 117. Note the unusual syntax for the passthrough parameter expression (the triple "@").

Template Expressions

As discussed above, you can think of template expressions (as placed on the template page) as statements, which makes the defined and referenced parameters usable on your template-driven child pages.

Expression Requirements

Expression Format - Template

Expression Examples - Template
Expression Type Expression Sample
Simple

@@(ParamName)@@ OR
<!-- TemplateExpr expr="ParamName" --> OR
<!-- #TemplateExpr expr="ParamName" -->

Notes:

  • The top expression can be used insidetags.eg.
    <a href=" @@(LinkURL)@@ "> Link</a>
  • The second and third expression cannotbe used inside tags.
  • The last expression is old technologyand we recommend that you don't use it since its functionalitywill likely be removed when Dreamweaver is next updated.
  • We recommend that you only use thetop expression format.
Complex @@(ParamName!="Me"?"True Resultant":"False Resultant")@@
Complex #2 @@(ParamName!="Me"?ParamName:OtherParamName)@@
Nested Complex @@(ParamName!="Me"?(OtherParamName=="You"?"foo":"bar"):"Idunno")@@
Region Lock @@(" ")@@ (Nested Templates ONLY)

Expression Results - Child page

Expression Examples - Child (Instance)
Expression Type Expression Sample
Simple Value of ParamName
Value of ParamName
Value of ParamName
Complex If ParamName!=Me - True Resultant
If ParamName=Me - False Resultant
Complex #2 If ParamName!=Me - ParamName Value
If ParamName=Me - OtherParamName Value
Nested Complex If ParamName != Me, then if OtherParamName = You - foo
If ParamName != Me, then if OtherParamName != You - bar
If ParamName = Me - I dunno
Region Lock Nothing at all except the contents of theeditable region, since this acts as a region lock in Nested Templates

Using Expressions in the Template

When you create a child page of a template, the template engine evaluates all expressions on the template page and writes the results of each evaluation to the child page. If the expression uses a parameter, then the template engine substitutes the parameter value wherever it sees the parameter used in an expression. If that expression uses the parameter's value in a calculation, the expression calculates a result uses it to display something. The template engine runs when you create a new page from the template and when you use Modify > Template Properties... The dialog box closes after you press OK button.

Because expressions can contain characters such as ', ", and @, you must convert them to the appropriate entities or character codes for the template engine to accept the values. See the conversion chart below.

Common Conversions

Character Character code/entity
' &#39;
" &#34; or &quot;
@ &#64;

Most of our tutorials at http://www.dreamweavermx-templates.com directly relate to parameters and expressions. Using this new knowledge, you'll be able to take advantage of other tutorials on our site.

Conclusion

Hopefully, the information we have provided clarifies template parameters andexpressions so that you can use them more easily!


About the authors

Although a biochemist by training, Murray Summers hasspent the last 20 years working in the computer industry. In 1998,Murray started his own website production company, GreatWeb Sights and he is the co-author of Dreamweaver MXTemplates. As a Team Macromedia member, he also participates in thesponsored forums for Dreamweaver and other products. He lives in ruralPhiladelphia with Suzanne, his lovely wife, their 13-year-old daughterCarly, a Golden Retriever, a mixed retriever, an Eskipoo, and somegoldfish.

 

Brad Halstead (www.dreamweavermx-templates.com), is aComputer Software Engineering Technologist by training, but deviatedfrom that dream to join the Canadian Military as an Air Weapons SystemsTechnician where he learned all about various computerized Aircraftweapons systems as well as loading the munitions. Brad has dabbledin the web in various capacities since 1989 and left the Military tobecome a full-time Computer Technician. Brad tries to play an activeroll in the support forums for Dreamweaver and Project Seven as timepermits him to. He lives in London, Ontario with his cherished partnerBrenda and their 9-year-old daughter Megan, 14-year-old daughter Amanda,13-year-old son Aaron, and 2 Yorkshire Terriers (17-F and 13-M).

Home | Audio | DIY | Guitar | iPods | Music | Links | Site Map | Contact

Top

Creative Commons License