9.6 Using templates

0002.jpg

When setting up a webpage you usually have sections of the page that are the same on each page. This includes a banner and navigation sections. An efficient way to do this is to enter these sections into a page and save that page as a template, which is then used to set up all the other pages in the site.

When changes are needed to the banner or navigation, those changes are just made to the template page and the changes are then automatically updated in all pages that were created from the template.

When creating templates for more detailed websites, HTML code is entered to divide a page into sections. The code is call DIV tags. To simplify things in this case, a table will be used to create a template that has banner, navigation and content sections as shown in the diagram.

Webpage authoring exercise 4

Creating a template page

Skills practised
  • Using tables
  • Using templates
  • Inserting images
  • Inserting text
  • Editable regions
  1. Open your Movie Magic site and select NEW from the FILE menu.
  2. Select HTML in the DOCUMENT TYPE frame then set the TITLE box to Movie Magic – Online Movies, check that the ATTACH CSS box is set to the styles.css file and select CREATE.
    TS0922.png
  3. Insert a table with the values shown in the diagram.
    TS0923.png
  4. Highlight the top row cells by dragging across them then display the EDIT menu, highlight TABLE and select MERGE CELLS so that there is just one cell across the top of the table.
  5. Drag the right border of the first cell in the second row to the left so that the width of the cell is about 200 px.
    TS0924.png
TS0925.png

Saving the page as a template

The program needs to know that the page is a template so that other pages can use it.

  1. Display the FILE menu and select SAVE AS TEMPLATE.
  2. Call the file mm_template.dwt and select SAVE.

Completing the template

A simple logo has been prepared for you, which will be inserted in the BANNER cell and some navigation text will be entered in the lower left cell.

  1. Click in the top cell and select the IMAGE icon in the INSERT tab of the PANEL GROUP.
  2. Open the LOGO image downloaded from the above link.
  3. Select YES to the ROOT FOLDER warning, open your Images folder and save the image.
  4. Click in the lower left cell and in the Properties panel set the VERT box to TOP so that the text starts at the top of the cell.
  5. Press <Enter> or <Return> to leave a blank line and enter the text shown in the diagram.
    TS0926.png
  6. Highlight all the words and use the TARGETED RULE box in the CSS section of the Properties panel to format them to the BODY_TEXT style.
  7. Open the HTML section of the Properties panel, click on the BLOCKQUOTE icon to indent the words and set the BG box to a medium blue or teal to add a background to the cell.
    TS0927.png
  8. Click in the bottom right cell and set its VERT box to TOP and its background colour to a dark blue or dark teal.

Setting the editable region

When you apply a template to another page you need to be able to make some changes to part of the page, otherwise every page would simply be identical. In this case the banner graphic and text need to be the same on every page, but the lower right (or largest) cell should have different content on every page. So we need to set the CONTENT cell to be an EDITABLE REGION.

  1. With the cursor in the lower right cell, set the Insert panel to TEMPLATES and click on the EDITABLE REGION button.
  2. Call the region content and select OK.
    TS0928.png
  3. Select SAVE ALL from the FILE menu to save all the documents.
Video 9.4 Using templates 1 (02:53)

Webpage authoring exercise 5

Creating pages from the template

Skills practised
  • Using templates
  • Copying content
  • Pasting content

The two pages that you have already created need to be set to the template. To do this, new pages will be created and the text and tables from the previous pages copied into the new pages.

  1. Display the FILE menu and select NEW.
  2. Select SITE TEMPLATES and your site’s template should be displayed. Select CREATE to start the new page.
    TS0929.png
  3. Open the home.html page, select all its contents (<Ctrl+A> or <Command+A>) and copy them (<Ctrl+C> or <Command+C>).
  4. Open the new page, highlight the CONTENT label in the lower right cell and PASTE the content in (<Ctrl+V> or <Command+V>).
    Note: The image may not display properly until you save the page.
    TS0930.png
  5. Use the FILE menu to save the page as index.html.
    Note: This will be the opening page for the website. Most internet service providers (ISPs) require the opening page to be called index.
  6. TS0931.png
    Create another new page from the template.
  7. Open the categories.html page, copy all the contents then open the new page, highlight the content label in the lower right cell and paste the content in.
  8. Save the page as categories2.html.
    Note: The home.html and categories.html pages can be deleted from your Movie Site folder using the FILES panel in the PANEL GROUP.
Video 9.5 Using templates 2 (01:52)
Skills practised
  • Using templates
  • Inserting text
  • Formatting text
  • Using tables

Some more pages are needed from the template: one to show the company’s contact details and a second to show some movie reviews. An ordering page will be created in a later exercise.

Creating the contacts page

  1. Create a NEW page from the template.
  2. Highlight the CONTENT label in the lower right cell, press <Enter> or <Return> to leave a blank line and enter the details shown in the diagram.
  3. A four-row, three-column table with a width of 400 px, no border, cell padding or cell spacing can be used for the address section. The first column can be left blank and the column widths adjusted.
  4. Format the heading to the Heading style and the rest of the text to the Table_Heading and Table_Text styles (or you can create some styles of your own to format the text).
    P0932.png
  5. Each line can be indented using the BLOCKQUOTE icon in the Properties panel.
  6. Save the page as contacts.html.

Creating the movie reviews page

  1. Create a NEW page from the template.
  2. Highlight the CONTENT label in the lower right cell, press <Enter> or <Return> to leave a blank line and enter the heading Movie reviews.
  3. Enter a review of a movie you have recently seen and format its text appropriately. If you cannot think of anything to review, the sample text in the diagram can be entered.
    P0933.png
  4. Save the page as reviews.html.