Flylib.com

Books Software

 
 
 

Optional Regions

Team-Fly    

Macromedia DreamWeaver MX Unleashed
By Matthew Pizzi, Zak Ruvalcaba
Table of Contents
Chapter 8.  Dreamweaver Templates


Optional Regions

An optional region is more or less a region that can be shown or hidden. This functionality can be determined either by the template author or the template user .

You can create an optional region in two ways: you can create it in the code view or you can create it in the Optional Region dialog box. The code you insert is a comment within the <head> portion of the HTML.

<!-- TemplateParam name="Name Something" type="Boolean" value ="false" -->

Code is also inserted into the area where you want the optional region to be placed. It looks something like this:

<!-- TemplateBeginIf cond="Name Something" -- > 
<p><Content you wish to show or hide></p>
<!-- TemplateEndIf -- >

Of course, you would substitute "Name Something" with a name that makes more sense for the region, and you would actually have HTML that would add content to the document between the <p> paragraph tags.

Of course, this is Dreamweaver's WYSIWYG HTML editor, so you may just want to set it up through the dialog box. There is generally less room for error that way. To insert an optional region in a template, follow these steps:

  1. Open a template by double-clicking it in the Assets panel.

  2. In the document, select the item you want to make an optional region.

  3. With the item selected, choose Modify, Template Objects, Optional Region. You also can click the Optional Region button in the Insert panel under the Templates tab or contextual-click the object and in the context menu, choose Optional Region. This will open the New Optional Region dialog box, as shown in Figure 8.12.

    Figure 8.12. The New Optional Region dialog box offers the options of creating statements to either hide or display the selected region.

    graphics/08fig12.jpg

  4. With the Basic tab selected, type in a name for the optional region. It's important to name this region something that will make sense to you later on. You will have to refer to this region by this name in a template-based document.

  5. If you want the region to appear, leave the Show by Default option selected; if not, uncheck that option. The user of the template will have the option of changing this value by selecting Modify, Template Properties. In the Template Properties dialog box, the user has the option of hiding or showing the optional area, as shown in Figure 8.13.

    Figure 8.13. This dialog box offers options for updating pages both with library items and templates.

    graphics/08fig13.jpg

  6. When you're happy with the settings, choose OK.

There is also an Advanced tab in the Optional Region dialog box. The reason is so you can write your own expressions to add functionality and options to the optional region. The template expression language is a small subset of JavaScript and uses JavaScript syntax and precedence rules.


Team-Fly    
Top
Team-Fly    

Macromedia DreamWeaver MX Unleashed
By Matthew Pizzi, Zak Ruvalcaba
Table of Contents
Chapter 8.  Dreamweaver Templates


Nested Templates

A nested template is a template whose editable regions and designs are based on another template. Nested templates are handy when designing pages with only slight variations between them. To create a nested template, you must first save a document as a template and then create a document based on that template. With the new template-based document, save it as a template, thus creating a nested template. Editable regions in the base template are then passed through to the nested template and remain editable when pages are created based on a nested template.

Nested templates are new to Dreamweaver MX and should be used only if you're dealing with very similar pages with only subtle differences between them. In the previous sections of this chapter, you looked at how you could broaden the customization features of templates, and nested templates offer more control only to the template author.

However, when using nested templates, you offer the template user some of the same functionality as the template author, although the user is able to manipulate only editable regions.


Team-Fly    
Top