Documentation Center

Creating optional regions

You can use optional regions in your Adobe Dreamweaver Template to display certain contents of the input package only if certain conditions hold.

About this task

For example, assume that your input package contains an array of Components, some of which are news articles (based on a Schema called NewsArticle), while others are product descriptions (ProductDescription Schema). If you want to display these items differently or in different areas of the Web page, you can distinguish between them by setting a condition for each type of Component (for example, the region for news articles would have a condition "Schema must be NewsArticle"). If the condition you set never holds, the region remains empty.

You can, of course, also filter on any other condition. You can also combine conditions to create complex Boolean expressions.

Procedure

  1. Start Adobe Dreamweaver and open an Adobe Dreamweaver Template.
  2. From the main menu, choose Insert > Template Object > Optional Region.

    The New Optional Region dialog opens.

  3. Click the Advanced tab and select Enter expression.

    Under Enter an expression, enter a condition for the optional region. To learn how to create conditions for optional regions, refer to Template expression language.

  4. Click OK to confirm your changes and close the dialog.
  5. The following tags define an optional region:
    <!-- TemplateBeginIf cond="BooleanExpression" -->
    ...
    <!-- TemplateEndIf --> 

    When the template is processed, the contents between the start and end tag are evaluated and only included if the expression specified evaluates to true.

    For example, to only render a Component Presentation if its Component is an Article, write the following code:

    <!-- TemplateBeginIf cond="Component.Schema.Name='Article'" -->
    	@@RenderComponentPresentation()@@
    <!-- TemplateEndIf -->