Creating a Web page template

Show Me

You can use page templates to define the look and feel of your Web site. With page templates, you can define the layout and the components that will appear on all pages using the page template.

Create a Web project.

Page templates are different from style sheets in that page templates are used to define the physical layout of the page, whereas style sheets are used to control how the page looks, for example with fonts and colors. If you make changes to the page template, the pages created from that page template are automatically updated.. You can create a page template in two ways:

  1. To create a new Web page template, complete the following steps:

    1. In the Enterprise Explorer, right-click on the folder in which you want to create the template, and click

      New | Web Page Template from the pop-up menu. The New Web Page Template window appears.

    2. Type the name of the file. You can optionally change the folder name in the folder field

    3. Select either a Design-time template or a dynamic template.

    4. Select a template from the list of templates. You can preview most of the templates in the preview box.

      Note that templates that you have previously created automatically appear under My Templates.

    5. Optionally uncheck the Link page to template check box. If you uncheck this box, you will be able to edit every part of the template in Page Designer. (In other words, if you uncheck this box, you are essentially making a copy of the page template for the new page). If you check this box, you will only be able to edit the content area of the template in Page Designer.

    6. Click Finish. The template appears in Page Designer.

    7. Add elements to the newly created page template. The common area is the part of the template that appears in each page that uses the template. The entire template is a common area by default; once you add a content area, the common area is the area surrounding the content area. Here are several ways to add elements to the common area of the page:

      • Enter text directly on the page and change attributes as needed.

      • Drag and drop components from the palette. The choices on the palette differ depending on what kind of page template you created. For example, if you have created a Faces components page template, you can drag and drop components from the Faces components drawer on the palette.

      • Open the Page Template drawer on the palette and drag and drop a page fragment to the page. A page fragment lets you include part of a page from another file (similar to an SSI include or a JSP include). Changes in the page fragment are also applied immediately to all the pages created from the template.

    8. Add a content area to the newly created page template. A content area is the section of the page that is filled in later by the pages that use the template. When you create a page from the template, the content area is editable, and the common area is fixed. Note that a page template must contain at least one content area. To add a content area:

      1. Open the Page Template drawer on the palette.

      2. Drag a Content area component and drop it to the page.

      3. When prompted, name the content area and click OK.

      4. If you are creating a design-time template, you can optionally add default content to the content area or instructions on what should go in the content area, such as "Insert title here."

    9. Choose

      File | Save and select the folder in which to save the template file. Now, you are ready to use the page template to create other new pages.

  2. To create a page template from an existing file:

    1. In Page Designer, open the existing HTML or JSP file that you want to be a page template.

    2. Insert a content area in the page. To insert a content area, open the Page Template drawer on the palette, drag and drop a content area to the page, and then add content to the content area. When you save the file, it is automatically saved as a template.

 

Related concepts

Page templates

Design-time page templates and dynamic page templates

Nested page templates

 

Related tasks

Laying out a page template with tables

Generating Web pages from page templates

Applying or replacing page templates to Web pages

Applying a page template to a Web site

Adding content to a page template

Creating a nested page template