Defining Optional Regions


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:

1.

Close any open documents and reopen the template.dwt file.

2.

Delete the existing Main Subheading editable region by selecting it and pressing Delete.

3.

With your cursor still in the cell, choose Insert, Template Objects, Optional Region. The New Optional Region dialog appears, similar to Figure 15.18.

Figure 15.18. The New Optional Region dialog allows you to establish an optional region in the template.


4.

The dialog is split into two tabs: Basic and Advanced. Although we'll discuss the Advanced tab later, for now make sure that the Basic tab is selected.

5.

On the Basic tab, you have the option of defining the name for the optional region as well as defining whether that region will display by default when the user opens the template-derived page for the first time. Enter the text Main SubMarketing into the Name text box and disable the Show by Default check box.

6.

Click OK.

7.

Replace the text in the optional region with the subheader_marketing.gif image located in the Images folder.

8.

Place your cursor next to the newly created optional region and perform steps 3 through 7 over again for both the engineering and sales images. When you've finished, the page should resemble Figure 15.19.

Figure 15.19. Add two more optional regions and two new images for engineering and sales.


9.

Save your work and update the pages that use the template.

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.

TIP

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:

1.

Close any open documents and open the engineering.htm page.

2.

Select the Template Properties option from the Modify menu. The Template Properties dialog appears, similar to Figure 15.20.

Figure 15.20. The Template Properties dialog reveals the three optional regions as well as the editable attribute.


3.

When you open the Template Properties dialog, the three optional regions become visible in the list. Also notice that their Boolean type is set as a true/false value. Because we're working with the Engineering page, select the Main SubEngineering option and click the Show Main SubEngineering check box. This action changes the Boolean value to TRue.

4.

Click OK. The Engineering subheading image becomes visible on the page.

5.

Save your work.




Macromedia Dreamweaver 8 Unleashed
Macromedia Dreamweaver 8 Unleashed
ISBN: 0672327600
EAN: 2147483647
Year: 2005
Pages: 237
Authors: Zak Ruvalcaba

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net