An optional region is a region in a template that users can set to show or to hide in a template-based document. Use an optional region when you want to set conditions for displaying content in a document.
When you insert an optional region, you can either set specific values for a template parameter or define conditional statements (If...else statements) for template regions. Use simple true/false operations, or define more complex conditional statements and expressions. You can later modify the optional region if necessary. Based on the conditions you define, template users can edit the parameters in template-based documents they create and control whether the optional region is displayed.
You can link multiple optional regions to a named parameter. In the template-based document, both regions will show or hide as a unit. For example, you can show a “closeout” image and sales price text area for a sale item.
Use an optional region to control content that may or may not be displayed in a template-based document. There are two types of optional regions:
- Non-editable optional regions, which
enable template users to show and hide specially marked regions
without enabling them to edit the content.
The template tab of an optional region is preceded by the word if. Based on the condition set in the template, a template user can define whether the region is viewable in pages they create.
- Editable optional regions, which enable template users
to set whether the region shows or hides, and enable users to edit
content in the region.
For example, if the optional region includes an image or text, the template user can set whether the content is displayed, as well as make edits to the content if desired. An editable region is controlled by a conditional statement.
You can edit optional region settings after you’ve inserted the region in a template. For example, you can change whether the default setting for the content is to be displayed or not, to link a parameter to an existing optional region, or to modify a template expression.
Create template parameters and define conditional statements (If...else statements) for template regions. You can use simple true/false operations, or define more complex conditional statements and expressions.
In the Advanced tab you can link multiple optional regions to a named parameter. In the template-based document, both regions will show or hide as a unit. For example, you can show a “closeout” image and sales price text area for a sale item.
You can also use the Advanced tab to write a template expression that evaluates a value for the optional region and shows it or hides it based on the value.
-
In Design view, click the template tab of the optional region you want to modify.
In Design view, place the insertion point in the template region; then in the tag selector at the bottom of the Document window, select the template tag, <mmtemplate:if>.
In Code view, click the comment tag of the template region you want to modify.
-
If you want to link optional region parameters, click the Advanced tab, select Use Parameter, then from the pop‑up menu select the existing parameter you want to link the selected content to.
If you want to write a template expression to control the display of an optional region, click the Advanced tab, select Enter Expression, then enter the expression in the box.
Opomba:
Dreamweaver inserts double-quotation marks around the text you enter.
-
When you use the Optional Region template object, Dreamweaver inserts template comments in the code. A template parameter is defined in the head section, as in the following example:<!-- TemplateParam name="departmentImage" type="boolean" value="true" -->
At the location where the optional region is inserted, code similar to the code below appears:
<!-- TemplateParam name="departmentImage" type="boolean" value="true" -->
<!-- TemplateBeginIf cond="departmentImage" --> <p><img src="/images/airfare_on.gif" width="85" height="22"> </p> <!-- TemplateEndIf -->