Establishing Basic Optional Regions


Think of a basic optional region as an area with an on/off switch. Turn the switch on, and the content within the optional region is there; turn it off, and the content within the optional region disappears.

For basic optional regions within a child page, the switch is contained in the Template Properties dialog box. The Template Properties dialog box displays a list of the available template variables in the page; for an optional region, its name is the template variable. Select an optional region, and a checkbox appears. Select the checkbox, and the optional region is displayed; deselect the checkbox, and the optional region is not displayed.

How Optional Regions Work

When you insert an optional region in a Dreamweaver template, Dreamweaver actually inserts code in two different page areas. In the <body> section, Dreamweaver inserts an opening and a closing HTML comment to indicate where the optional region starts and where it ends:

 <!-- TemplateBeginIf cond="OptionalRegion1" --> Optional content goes here <!-- TemplateEndIf --> 

The attribute in the TemplateBeginIf statement labeled cond (short for conditional) holds the name of the optional region. As with editable regions, a thin border surrounds the optional region; the name of the region appears in a small tab, prefaced by the word "If" to distinguish it as an optional region.

The second part of the optional region is placed in the <head> of the document and looks like this:

[View full width]

<!-- TemplateParam name="OptionalRegion1" type="boolean" value="true" -->

Note that the value of the name attribute in the TemplateParam statement is the same as that of the cond attribute in the TemplateBeginIf statement. The TemplateParam statement controls the display of the same-named TemplateBeginIf/TemplateEndIf area by the state of the value attribute. When value is set to TRue, the designated optional region is included on the child page; when value is set to false, the area is omitted. As you'll see in Lesson 9, there are many types of TemplateParam statements; those for optional regions always include type="boolean".

Optional regions are not like layers that can be hidden or made visible. The content in layers (or <div> tags) is always present on the page, and the tag's visibility attribute controls whether or not the browser renders the content. Optional regions are a Dreamweaver design-time tool. If an optional region is set to be displayed, Dreamweaver actually inserts the declared content. When the optional region is set not to be shown, the content is not inserted onto the page at all.


Optional regions can contain any other page elementincluding other template regions. In this lesson, you'll make some existing content (both locked and editable) optional. In addition, you'll insert a second optional region with new locked text and a new editable region.

1.

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

For this lesson, let's say that you decided to expand the usability of the Dean's letter template created in Lesson 7. The first task is to make all the capital growth fund material optionalincluding the heading, the editable region for the body text, and the table embedded with editable regions.

2.

In Split view, select all the content from the heading Capital Growth Fund up to and including the table labeled Capital Fund Participation. Use Code view to ensure that all the contentfrom the opening <h1> tag to the closing </table> tagis selected. From the Insert bar's Common category, select Templates: Optional Region. When the New Optional Region dialog box opens, delete the default suggested name OptionalRegion1 on the Basic tab and enter capitalFundSection. Leave the Show by Default option selected. Click OK when you're ready.

It's critical that all content within an optional region be self-contained. You cannot have an opening HTML tag outside of an optional region and the corresponding closing tag inside it. When working with large areas, I find that making the initial selection in Design view and then tweaking it in Code view to be the quickest approachthat's why Split view, which combines both, is ideal.

Choosing a proper name for an optional region is extremely important. When the template is modified in Contribute, the Contribute user sees only the name in the Template Properties dialog box. Use a meaningful name that indicates the region's purpose rather than a generic name such as OptionalRegion1.

Optional regions can be shown or hidden by default; every time a new child page is created, the default state is used. If that state is altered, Dreamweaver and Contribute recognize and apply the change every time the child page is reopened until it is changed again. If the region is more likely to be used than not, as in this case, keep the Show by Default option checked. The next optional region, inserted in the following step, will be disabled by default.

3.

Place your cursor below the optional region just created below the table and enter this text: In Conclusion. With your cursor still at that end of that line, choose Heading 1 from the Property inspector's Format list. Press Enter (Return) to create a new paragraph and then enter the following text:

Closing text goes here. Two to three short paragraphs are best, but exact structure is up to the writer's discretion.

Although it's possible to insert an optional region and then add the content, I've always found it easier to apply an optional region to existing content. Dreamweaver has a tendency to place the tags of the first heading outside of a newly inserted optional region. Although that can be desirable for editable regions, it's definitely not the right approach for optional regions.

4.

Place your cursor in the placeholder paragraph entered in the preceding step and choose the <p>tag from the Tag Selector. From the Insert bar, choose Templates: Editable Region;when the New Editable Region dialog box appears, enter inConclusionText in the Name field and click OK. Using Split view, select both the In Conclusion heading and the just-created editable region. Choose Templates: Optional Region from the Insert bar. In the New Optional Region dialog box, enter inConclusionSection in the Name field; deselect the Show by Default checkbox and click OK.

Although the two optional regions have different default statesone is set to be shown and the other notthere is no visible difference when working on the template. The difference, however, is readily apparent on a child page derived from the template.

Note

Although there is an Editable Optional Region object, it doesn't wrap around selected content properly. I find it far more controllable to do the operation in two steps: Add the editable region first and then add the optional region.

5.

Choose File > Save to store the revised file; click OK to acknowledge Dreamweaver'snotice concerning the editable region within a block tag. Select Put from the File Managementbutton on the Document toolbar. If the Dependent Files dialog box opens, click Yes.

As with previous templates, you'll now try out your modifications on a child page created in Contribute.

6.

In Contribute, click New Page. If you 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.

The first difference is the message bar across the top of the document window that informs you, among other things, that some items on this page can be edited only by setting template properties. The template properties link opens the Template Properties dialog box.

What you won't see on the page is any indication of optional regionsthe content is either there or not, and it is not marked in any way. The message bar is the only visual clue for Contribute users that optional regions are embedded in the page.

7.

Click the template properties link in the message bar. In the Template Properties dialogbox, with the capitalFundSection optional region selected, clear the Show capitalFundSectioncheckbox. Click Apply to view the modified page. Select the second optional region and enable the Show inConclusionSection option. Click OK.

Now the page has a completely different but consistent layout. Naturally, any combination of optional region states is possible. If you need to modify it again after this page is published, the optional region states last set will be in effect.

8.

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