Customizing Templates with Other Region Types So by now, you should really be hoppin' with templates. I told you they were the coolest part of Dreamweaver! But there's more! So far, you've been working only with editable regions. As you've seen, editable regions are very useful for limiting the changes that a template user can make. However, you can enhance your templates with other types of regions as well.In this section, you'll see how to set optional regions, which are regions that the template user can choose to either hide or displayperfect for page elements that you may want to appear on some pages but not on others. You'll also see how create a region with an attribute that's editable. For example, maybe you want to allow the person who's editing a template-driven page to change a graphic, but you don't want the person changing the image's width or height or the hyperlink that's been set. You can do this by setting an editable attribute. Finally, you'll see how to work with repeating regionsareas in a template that can be duplicated as many times as needed on pages that are based on the template.
Setting Optional Regions .Here's how to insert an optional region:
1. | In your template, select the page object whose visibility you want to control in an optional region.[View full size image] You can select a graphic, a layer, text, or any other page element that you want. | 2. | Choose Insert > Template Objects > Optional Region. | 3. | In the New Optional Region dialog box that appears, give your optional region a name.[View full size image] This name will appear in pages that are being controlled by the template, so you should make the name descriptive. | 4. | Select or deselect the Show by Default check box; then click OK.If you turn on Show by Default, your selected page object will appear by default on template-based pages. If you turn it off, the object will be hidden by default. Either approach will work, though you'll probably want the default setting to be the one you'll use most often.When you click OK, Dreamweaver places a light blue frame around your selected page object, with a tab at the top that contains your optional region's name, preceeded with If. | 5. | Continue adding optional regions by repeating steps 1 through 4.[View full size image] Once you've created all the optional regions you need, you're ready to save your template and update your pages. | 6. | Choose File > Save; then in the Update Template Files dialog box that appears, click Update. In the Update Pages dialog box that appears, click Close when the update is complete.With your template-based pages updated, you can now control the visibility of your optional regions from each page controlled by the template. | 7. | Open a page that is being controlled by your template by either choosing File > Open or double-clicking the page in the Files panel. | 8. | In your open page, choose Modify > Template Properties. | 9. | In the Template Properties dialog box that appears, select the optional region whose visibility you want to control; then at the bottom of the dialog box, click the Show check box. Click OK when you're done.[View full size image] When you click OK, the visibility setting is applied to the object that appears within the optional region. For example, if your page object's visibility was turned on by default and you unchecked the Show check box in the Template Properties dialog box, then the page object would disappear. |
Setting Editable Tag Attributes As you've seen, content that resides in an editable region is fully editable. That may be fine for most areas in your template, but sometimes you may want more detailed control over what, specifically, is editable within a region.An editable attribute determines what's editable in an editable region on a template-driven page, and what isn't.For example, you may want people working with your template-based pages to be able to change a graphic, but you don't want them to be able to change the graphic's width and height. In other words, you want very specific aspects of a page object to be editable, but you want to retain control over the other aspects. To set up your pages in this way, you can create an editable attribute, which determines what's editable in an editable region on a template-driven page, and what isn't.The only catch here is that to use editable attributes, you need a decent understanding o90 tags and the attributes and values that can be used in each. If you're not handy wit92 coding, you may find Dreamweaver's Reference panel (choose Window > Reference) helpful when setting editable attributes.Here's how to set an editable attribute:
1. | Select the page element whose attribute you want to make editable.
Inserting Editable Optional Regions Optional regions are very useful not only for keeping your pages consistent, but also for making updating easy for people working on your template-driven pages. However, you may have noticed something: the content inside optional regions isn't editable!What if you want to set up a template region whose visibility can be controlled, but also whose content is editable? What you need is an editable optional region.To insert an editable optional region, follow these steps:
1. | Select the page element that you want to set as an editable optional region. | 2. | Choose Insert > Template Objects > Editable Optional Region. | 3. | In the New Optional Region dialog box that appears, enter a name for the editable optional region; then set the default visibility of the region with the Show by Default option. Click OK when you're done.Dreamweaver inserts the editable optional region into the template; it appears as an editable region within an optional region, indicated by the two tabs at the top left of the region.[View full size image] | 4. | Dreamweaver gives the editable region a default name. To change it, click the editable region's tab; then rename the region in the Property Inspector. |
When your template is saved and your pages have been updated, you can control your editable optional region's display through the Template Properties dialog box, just as before. When an editable optional region is displayed, you can edit its contents just as you normally would. |
| 4. | Select the Make Attribute Editable check box.When this option is selected, the Label, Type, and Default fields become available. | 5. | In the Label field, type a unique name for your editable attribute.The label is just like a name for an editable region. Users of the template-driven pages will use the name you use here to identify an object on the page whose attributes are editable. Therefore, make the name descriptive. | 6. | Select an option from the Type pull-down menu. Text: Choose Text if the editable attribute's value is text based. For example, use Text if you're making a table cell's valign attribute editable. When Text is selected, a text box will appear in template-driven pages where the user can type a valid value for the attributein this case, Top, Middle, Bottom, or Baseline.URL: Use URL if the editable attribute's value requires a path to a file. For example, you might make the src attribute of an image editable. Template-based pages would provide a field with a browse icon, where the user could specify a path to a graphic; all other attributes for the image would be locked.Color: Set Color if the editable attribute requires that a color be specified. If you're making the bgcolor attribute of a table cell editable, for example, then with Color set, Dreamweaver's color picker will appear in the template-driven page so that the user can specify the background color.True/False: Use the True/False setting when your editable attribute's value is either true or false (called a Boolean attribute). For example, you could set an inserted audio clip's hidden attribute so that it can be controlled within the template-driven pages.Number: Select Number when a numeric value is needed for the editable attribute. For example, if your editable attribute is a table's width attribute, the user of the template-based page will be able to enter a numeric value. | 7. | In the Default field, set a default value for your editable attribute; then click OK.The default value will be the value that's initially set for your tag. For example, it could be the initial background color of a table cell or the initial width and height of a graphic.Now you're ready to manipulate the editable attribute within a template-based page. First, though, you need to save your template and update your pages. | 8. | Choose File > Save; then in the Update Template Files dialog box that appears, click Update. In the Update Pages dialog box, click Close.You can now set values for your editable attribute. | 9. | Open a page that is being controlled by your template, either by choosing File > Open or double-clicking the page in the Files panel. | 10. | In your open page, choose Modify > Template Properties.The Template Properties dialog box that appears lists all available properties and their default values. | 11. | Select the editable attribute whose value you want to manipulate; then at the bottom of the dialog box, set a new value. When you're done, click OK.[View full size image] The type of value you set for your editable attribute back in Step 6 determines the type of setting you can make. For example, if you chose Text, a text box appears; if you chose Color, a color picker appears; and so on.When you click OK, the value is applied to the page element associated with the editable attribute. |
Setting Repeating Regions Repeating regions are areas in your template that can be duplicated as often as they're needed on pages that use the template. For example, the template for a newsletter could control the look and formatting of an article, including its headline; then the article object could be placed inside a repeating region. The newsletter's editor can then duplicate the region on template-based pages as many times as there are articles on that page. The template controls what repeats, but the user controls the number of times the object is repeated on the pages that the template controls.Repeating regions are areas in your template that can be duplicated as often as they're needed on pages that use the template.To make the content in a repeated region editable, you can insert an editable region inside a repeating region. Otherwise, you can simply set the region to repeat in its entirety.Repeating regions often are used inside tables, to repeat rows as often as they're needed. For this purpose, Dreamweaver includes a separate command, discussed in the sidebar "Constructing a Repeating Table."Here's how to set up repeating regions in your template:
1. | Select the area in your template that you want to set as a repeating region.You can select any page element or group of page elements that you want to repeat.[View full size image] | 2. | Choose Insert > Template Objects > Repeating Region. | 3. | In the New Repeating Region dialog box that appears, give your repeating region a unique name; then click OK.Dreamweaver outlines your repeating region in a light blue frame with a tab at the top left that displays Repeat: and your repeating region's name.[View full size image] | 4. | Do one of the following:If you want the content in your repeating region to be editable, then you must insert an editable region inside your repeating region. With your repeating region content still selected, choose Insert > Template Objects > Editable Region. In the New Editable Region dialog box, give your editable region a name and click OK. Then choose File > Save. Dreamweaver outlines your editable region in a turquoise frame.[View full size image] If you simply want to be able to duplicate the editable region's existing content in your template-based pages, choose File > Save.
| 5. | In the Update Template Files dialog box that appears, click Update. In the Update Pages dialog box, click Close. | 6. | Open a page that is being controlled by your template, either by choosing File > Open or by double-clicking the file in the Files panel.In your template-driven page, you'll see the light blue tab containing Repeat: and the name of your repeating region, as well as plus (+), minus (), and up and down controls. You can use these controls to duplicate, delete, and change the order of the repeated entries on your page.[View full size image] | 7. | Do any of the following:Click the plus (+) button to duplicate the content in your repeating region.Click the minus () button to remove a repeating region entry. You can remove an entry only from an area that is editablejust be sure to click inside it first.Use the up and down arrows to change the order of your repeating region entries. Reordering applies only to repeating regions that also contain editable regions; first click inside the region that you want to reorder before using the up and down arrows. If you don't see the plus (+), minus (), and up and down controls in your template-based pages, choose View > Visual Aids > Invisible Elements. | 8. | If you inserted an editable region inside your repeating region, make any changes that you want to the content contained in the region.[View full size image] |
Constructing a Repeating Table Repeating regions often are used in tables. For instance, you may want to control the look of a table that will contain a list of products, but you want the number of products included to be determined on the template-driven page. By creating a repeating table, you can set up the formatting of the table and then allow the user of the template-based pages to determine the number of rows in the table.Here's how to insert a repeating table:
1. | In your template, place the cursor where you want to insert the repeating table. | 2. | Choose Insert > Template Objects > Repeating Table. | 3. | In the Insert Repeating Table dialog box that appears, set values for the number of rows and columns, the table's width, border, cell padding, and cell spacing.Carefully think about the number of rows you add. You have to consider not only how many rows you want to set to repeat, but also how many rows you want to remain stationary. For example, you might want two rows that repeat and a header row and a footer row that remain stationary. | 4. | In the Starting Row and Ending Row fields, insert the row numbers for the rows you want to allow the template user to repeat.For example, if you want the first two rows in your table to repeat, set Starting Row to 1 and Ending Row to 2. If you want just the first row to repeat, set both the Starting Row and the Ending Row fields to 1. The rows that you set to repeat must be contiguous. You can't, for example, make row 1 and row 3 repeat with this command. | 5. | Type a descriptive name in the Region Name field; then click OK.The repeating table is inserted into your template, with editable regions inserted automatically into each cell in the rows that you set to repeat. Any content you enter into the editable regions will be editable on template-driven pages, while any content you insert into the remaining cells in your table will be locked. | 6. | Save your template and update your pages; then in your template-driven pages, use the plus (+), minus (), and up and down controls just as for repeating regions. |
|
Just the Gist Started with TemplatesTemplates in Dreamweaver are used to drive the content and layout of multiple pages in your web site.Templates contain areas called editable regions. On a page controlled by a template, the content within editable regions can be edited. All other areas of the page are locked. Creating TemplatesTo create a template, a good approach is to first create a page that you want to use as the basis for other pages in your site. Include placeholder content for text and images that will be replaced with actual content in the template-driven pages.To create a template, choose File > Save as Template.To insert an editable region, select the content that you want in the region and choose Insert > Template Objects > Editable Region.To create a new page based on a template, choose File > New, select a template, and click Create. Updating a TemplateAny changes made to elements in a template that do not reside in an editable region automatically update on any pages based on the template.Before updating a template, it's a good idea to close any pages based on the template that are open in Dreamweaver.To update a template and the pages it controls, open the template, make changes, and save the file. Then click Update. Working with Nested TemplatesA nested template is a template whose content and formatting is controlled by another template.To create a nested template, open an existing template and choose File > Save as Template. A nested template is created automatically whenever you save a template-driven page as a template.Only areas that appear within editable regions in the master template are editable in a nested template. Customizing Templates with Other Region TypesOptional regions are areas in a template that can be turned on and off, depending on whether you want the element in the region to appear on a page. To insert an optional region, choose Insert > Template Objects > Optional Region.Set editable attributes to control which aspects of an editable region can be edited and which are locked. To make an attribute editable, choose Modify > Templates > Make Attribute Editable. Then set the attribute you want to make editable and the type of value that the attribute will accept.Repeating regions are areas in the template that can be duplicated as often as they're needed. A repeating region can be set to contain an editable region. To set a repeating region, choose Insert > Template Objects > Repeating Region.
|
 |