Optional regions are some of the more powerful customizable regions. Optional regions allow you to list multiple options, such as images, within a region on the template and then allow the user of the template-derived page to determine which image he or she wants to use. To further understand how the optional region can be beneficial to a template, think about our Dorknozzle organization. Currently, we specify an image placeholder in the Main subheading's editable region. We automatically assume that the department web developer will browse the company's directory of images (tedious work, by the way) and find the appropriate image to place in that area. Technically, there's nothing preventing the department web developer from selecting a custom image that he created to put into that spot instead. By creating an optional region in this spot instead of an editable region, we get to dictate which images the developers can choose from. For instance, in the Images folder, we have three versions of the subheader image: subheader_engineering.gif, subheader_marketing.gif, and subheader_sales.gif. We could easily replace the Main Subheading editable region with three optional regions, effectively forcing the department web developer to pick one of the three. To demonstrate how this is done, follow these steps:
Combining Editable and Optional Regions
On occasion, you may find that an optional region has to contain editable text as opposed to an image as we've outlined in the previous section. To handle this, Dreamweaver provides the Editable Optional Region option. Available by choosing Insert, Template Objects, Editable Optional Region, the Editable Optional Region feature establishes an editable region within the boundaries of an optional region.
Of course, you can also add an editable region to an existing optional region without using the Editable Optional Region option. To do this, simply place your cursor in the optional region and choose Insert, Template Objects, Editable Region.
Setting Optional Region Properties
Like editable attributes, optional regions are inserted into the document as instance parameters. To demonstrate this, switch to Code view and notice the following three lines of code:
<! InstanceParam name="Main SubMarketing" type="boolean" value="false" > <! InstanceParam name="Main SubEngineering" type="boolean" value="true" > <! InstanceParam name="Main SubSales" type="boolean" value="false" >
Like editable attributes, the optional region is an instance parameter that can be set using the Template Properties dialog by the user of the template-derived page. Unlike editable attributes, however, the parameter attributes in the InstanceParam tag are slightly different. By default, optional regions are set as type Boolean because their visible values are either shown (true) or not shown (false). The Type and Value properties of the InstanceParam tag reflect these properties.
As a user of a template-derived page, you can easily set these parameters on the page using the Template Properties dialog. Because we've started working with the engineering.htm file, go ahead and reopen that page so that we can set which heading image becomes visible. To do this, follow these steps: