Making Dependent Optional Regions


Each optional region previously inserted in this chapter stood on its own; whether the content in the region was shown or not depended on a variable set for each optional region. This level of interaction is fine when working with independent areas that can be displayed or hidden in any combination. As you develop more complex templates, however, you'll want to include several regions that all need to be enabled or disabled according to the state of a key region. Optional regions such as these are said to depend on the main region and are referred to as dependent optional regions. Both Dreamweaver and Contribute support dependent optional regions.

Optional regions include an attribute of type="boolean". A Boolean statement is one that is either true or false. With dependent optional regions, if one region is set to true (that is, it is shown), other regions are also shown. Standard optional regions are defined using the Basic tab of the New Optional Region dialog box; dependent optional regions use the Advanced tab.

In this lesson, you'll add a noneditable optional region that is dependent on an existing optional region.

1.

In Dreamweaver's Files panel, expand the Templates folder and double-click the dean_letter_v2.dwt file to open it.

The goal of this lesson is to enhance the design of a page without adding to the Contribute user's workload. Although it would be entirely possible to include another optional region with its own entry to be set in Template Properties, dependent optional regions make that procedure superfluous.

2.

Place your cursor after the From the Dean's Desk graphic and press Shift-Enter (Shift-Return) to insert a line break tag: <br />. Then, from the Insert bar's Common category, choose Images: Image. When the Select Image Source dialog box opens, expand the images folder in the site root and choose capital_fund_update.gif. Click OK to insert the image.

The key concept to grasp at this point is that the optional region you're about to add (the graphic just added) is not within or connected at all to the region it depends on: capitalFundSection.

3.

Select the GIF image just added to the page. From the Common category of the Insert bar, choose Templates: Optional Region. In the New Optional Region dialog box, select the Advanced tab. Make sure that the Use Parameter option is selected and choose capitalFundSection from the associated drop-down list. Click OK when you're done.

In Design view, you'll note the now-familiar thin blue outline and tab labeled If capitalFundSection. If you switch to Code view, you can see that the template statement is the same as the one previously added with the capitalFundSection optional region that we originally created:

 <!-- TemplateBeginIf cond="capitalFundSection" --> 

Because a template parameter already exists for capitalFundSection, another is not inserted. Both optional regions have the same condition value referencing the single template parameter, so it controls both their states.

4.

Choose File > Save to store the revised file; when the notice concerning the editable region within a block tag appears, click OK to acknowledge it. Select Put from the File Management button on the Document toolbar to copy the revised template to the remote site. If the Dependent Files dialog box opens, click Yes.

The proof, as they say, is in the pudding, so let's try out the enhanced template in Contribute.

5.

In Contribute, click New Page. If you've had Contribute open while working in Dreamweaver, when the New Page dialog box opens click Refresh Templates. Expand the Templates folder under the Design_Deploy site and select dean_letter_v2. In the Page Title field, enter Test Page and click OK.

After the test page has been created, you should see the newly added image immediately. This is to be expected becauae the controlling optional region, capitalFundSection, is displayed by default.

Tip

Although many users will find the template properties link to be the quickest way to open the associated dialog box, you should be aware that another route is available from the main menu: Format > Template Properties.

6.

Choose Format > Template Properties. In the Template Properties dialog box, select the capitalFundSection entry and deselect the Show capitalFundSection option. Click OK.

As you can see, not only does the initial optional region disappear, but so does the dependent optional region just established. You can probably easily imagine how this ability can be applied to other design possibilities. For example, you could establish a different subnavigation system as well as a different logo and layout tied to a single optional region.

Note

In Lesson 9, you'll further extend the uses of optional regions through the application of template parameters and template expressions.

7.

When you're done testing, click Cancel. Confirm that you want to delete the new page by clicking Yes when prompted by Contribute.



Design and Deploy Websites with Macromedia Dreamweaver MX 2004 and Contribute 3(c) Training from the Source
Design and Deploy Websites with Macromedia Dreamweaver MX 2004 and Contribute 3: Training from the Source
ISBN: 032128884X
EAN: 2147483647
Year: 2006
Pages: 130
Authors: Joseph Lowery

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