13.1. Working with Dynamic Web Templates

Dynamic Web templates (DWTs) is an HTML-based SharePoint Designer feature that allows you to create templates and then use them on Web pages of your Web site. As mentioned earlier, you design the template in a DWT template file (having the extension .dwt) and then place unique areas called editable regions at the required locations in the template file. After you create the template file, you can either create new pages based on it or attach it to existing pages.

NOTE

To be able to use DWTs on your Web site, you need to enable the use of hidden metadata. You can do this by clicking the Manage the Web site using hidden metadata check box in the General tab of the Site Settings dialog box. To open this dialog box, choose Site Site Settings.

13.1.1. Creating and attaching dynamic Web templates

In this section, I take you through the steps to create a dynamic Web template and then add editable regions to it. Then, I show you how you can create new pages based on this template:

  1. Open your Web site in SharePoint Designer and then choose Site Site Settings to open the Site Settings dialog box. Ensure that the Manage the Web site using hidden metadata check box is selected.

  2. Choose View Toolbars Dynamic Web Template to enable the Dynamic Web Template toolbar. This toolbar comes in handy while creating DWTs.

  3. Choose File New to open the New dialog box, and in the Page tab, under the General section, select Dynamic Web Template and then click OK. This creates a new Web page with the extension .dwt and opens it in the Design view.

  4. Using the SharePoint Designer tools and features, design the DWT to suit your requirements. As shown in Figure 13.1, for illustration purposes, I created a simple Web page design by using tables. The next step is to insert editable regions in this DWT. Editable regions are the unique areas that are editable on the Web pages attached to the DWT.

    Figure 13.1. Designing a Dynamic Web Template
  5. Place the cursor at the location on the DWT where you want to add an editable region, right-click on the DWT in the Design view, and then choose Manage Editable Regions from the popup menu. The Editable Regions dialog box, as shown in Figure 13.2, opens. By default, there are two editable regions, doctitle and body, that are placed by SharePoint Designer on the DWT. The doctitle editable region facilitates editing the title of the Web page attached to the DWT.

  6. To add a new region, type a name for it in the Region name text field and then click Add. As shown in Figure 13.3, in the DWT in the background, the editable region is inserted at the location where the cursor was located.

    Figure 13.2. The Editable Regions dialog box

    Figure 13.3. Adding editable regions on DWTs
  7. Click Close. Place the cursor at the location on the DWT where you want to add another editable region and then open the Editable Regions dialog box again. Then, add another editable region, as shown in Figure 13.4. Repeat these steps to add more editable regions to the DWT.

    Figure 13.4. Multiple editable regions inserted on a DWT
  8. Save the DWT by pressing CTRL+S or choosing File Save. The DWTs need to be saved with the extension .dwt.

Now that you have created a DWT for your Web site, you can use it to create new Web pages. To create new Web pages based on an existing DWT, follow these steps:

  1. Choose File New Create From Dynamic Web Template. The Attach Dynamic Web Template dialog box opens, allowing you to choose the DWT that you want to use for the new Web page.

  2. Select the DWT and then click Open. SharePoint Designer creates a new Web page and then attaches the selected DWT to the Web page. Once finished, SharePoint Designer shows an update message, as shown in Figure 13.5. This message box indicates that SharePoint Designer has attached and updated the new Web page with the selected DWT.

  3. Click Close and then save the newly created Web page. When you open this page in the Design view, you're only able to edit the Web page within the editable regions that you previously defined in the DWT. Editing the rest of the Web page is prohibited in the Design view. This is illustrated in Figure 13.6.

    Figure 13.5. Creating a new Web page based on a DWT

If you open the Web page in the Code view, all the code from the DWT actually exists in the attached Web page. However, the code from the DWT is highlighted. If you try to modify the highlighted code, you receive an update message, as shown in Figure 13.7.

As indicated in the message, the changes that you make to the noneditable code from the DWT are discarded when the DWT is modified and saved. However, you're provided with an option to detach the Web page from the DWT.

NOTE

Modifying the content of the editable regions in the DWT doesn't really make much sense because you would always modify them in the attached Web pages.

Figure 13.6. Editing a Web page attached to a DWT

Figure 13.7. Modifying the code from the DWT in the Code view of the attached Web page

Choosing Format Dynamic Web Template allows you to pick from a number of DWT-related actions you can perform on a Web page:

  • Attach Dynamic Web Template: Opens the Attach Dynamic Web Template dialog box, which allows you to attach a DWT to the active Web page

  • Detach from Dynamic Web Template: Detaches the DWT from the Web page. The content of the DWT still remains on the Web page. However, the content is now all editable.

  • Open Attached Dynamic Web Template: Opens the DWT attached to the Web page

  • Update Selected Page: When the active Web page in SharePoint Designer is a DWT, this option updates the selected page with the modifications made to the DWT.

  • Update All Pages: Regardless of the selection, this updates all pages attached to the active DWT.

  • Update Attached Pages: Updates all the Web pages that are attached to the DWT

  • Manage Editable Regions: Opens the Editable Regions dialog box, which you can use to add and modify editable regions on the DWT

The Dynamic Web Template toolbar allows you to view all the editable regions associated with the selected DWT and provides another access point to the Editable Regions dialog box. It also has a Template Region Labels button, which can be used to toggle the display of the editable region names in the Design view of the Web page.

13.1.2. Managing editable regions

While the Editable Regions dialog box can be used to perform the usual job of adding, modifying, and removing editable regions on a DWT, it also hosts one feature that allows you to control and channelize designers working on SharePoint sites. Combined with the Contributor Settings feature available in SharePoint Designer for SharePoint sites, the Editable Regions dialog box can be used to define control on the type of modifications that are allowed in an editable region.

NOTE

For more on the Contributor Settings feature, see Chapter 24.

Using the Contributor Settings feature in SharePoint Designer, you can create region types and define what authoring actions and features are allowed in the region type. For example, you can define a region type that doesn't allow inserting images.

Using the Editable Regions dialog box, you can associate a region with a region type. When you add an editable region to a DWT inside a SharePoint site, you have the option to choose from a number of region types. If Contributor Settings are enabled for a SharePoint Web site, a number of regions are available by default. As shown in Figure 13.8, you can associate an editable region with one of the available region types.

After the association is made, the editable region is controlled by the settings of the associated region type. If the region type is configured to disallow use of a certain SharePoint Designer feature, the editable region doesn't allow the designer to perform that operation in SharePoint Designer.

Figure 13.8. Associating regions with region types

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.131.180