1 - Introduction

 2 - Quick start

 3 - Using KompoZer

 4 - Stylesheets

 5 - Scripts

 6 - Inserts

 7 - Templates

 8 - Site Manager

 9 - Preferences

10 - Publishing


This page was composed using KompoZer

Traduction française

KompoZer User Guide - Section 7

7    Templates

7.1    What are templates?

Templates are basically pages having some content (eg a letter head) which can be re-used to create other pages which will have the same underlying page structure and, often, the same graphical layout.

Templates are not altered in use and can be used over and over again. The simplest template is probably a blank sheet which links to a stylesheet for use throughout a site. More common is a page which has a banner and perhaps a menu to appear on every page. Last might be a complete page layout for use on all, or many, pages of a site but which includes areas for customising individually.
Templates may be considered as having two parts – the fixed part or ‘boilerplate’ which remains the same for every page and the editable part which changes.

KompoZer recognises two types of editable part. Block and flow. Block items are like any other html block and may consist of paragraph-like items or divs (which may contain several blocks). Blocks may be made repeatable - so that several similar items may be added if required.

Flow items will be contained within other block items in line with the text, for instance to change one or two words in a paragraph.

7.2    Create a new template

Initial page layout with boilerplate textTemplates are prepared and edited using KompoZer just like any other page.
To create a template

  1. Click File > New then select ‘A blank template’ and ‘Create’. Note All templates will be created with the Transitional HTML Doctype.
  2. Add any content which is to appear on all pages based on the template.
  3. Format this in the normal way.
  4. If the formatting is to be based on a style sheet prepare this in the normal way as detailed in section 4.2.4.
    Note For this to be successful the template must first be saved.
  5. Add the areas which are to be made editable.

Fill these in using dummy text so that a complete page layout is achieved even though some of it may be meaningless. Format this as required.

Note Useful dummy text can be found at http://www.lipsum.com/.

Note There are other approaches to page layout but the method described is simple and reliable.

The first figure shows a page prepared as described.

7.3    Saving templates

To save a template

  1. Click File > Save or File > Save As.

The extension ‘mzt’ will be selected automatically.

7.4     Create a template from a page

A pre-existing document may be transformed into a template

  1. Click Format > Page Title and Properties
  2. Check the box ‘This page is a template’.
  3. Click OK.
  4. Click File > Save as. The file type ‘HTML Template’ will be completed.
  5. Name and save the file as normal.

7.5     Setting up template details

The content of the page - boilerplate and examples of editable content - should already be set up and formatted.
Page with editable areas addedTo make blocks editable

  1. In turn, select each block that you wish to make editable.
  2. In HTML tags view select the block by clicking its tag.
  3. On the status bar right-click the corresponding highlighted tag.
  4. Click Templates > Make editable.
  5. In the ‘Insert an editable area’ window give the block a recognisable name. Now check the options boxes if required.

Note The option ‘Area is optional’ allows it to be deleted easily when the page is in use. ‘Area is repeatable’ allows copies to be made rapidly. ‘Area is moveable’ turns the area into a movable layer (see section 3.10).

Warning In KompoZer 0.7.10 this option is disabled

6.  Click OK

To make a flow selection editable

  1. In turn select (highlight) each section of text that you wish to make editable.
  2. Click Insert > Templates >Insert editable area.
  3. In the ‘Insert an editable area’ window give the block a recognisable name.
  4. Leave checked the option ‘Flow of text’.
  5. Check the options boxes if required as described above.

Note The option ‘Area is moveable’ is inappropriate for flow areas).

6.  Click OK

When you have finished save the template as described in section 7.3

The second figure (above) shows a template at this stage. It has one non-repeatable block item - The program name, Two non-repeatable flow items - The Date and Language, Two repeatable flow items - The Changed areas and Other languages; the second of these is optional.

Template in use with editable areas filled in7.6    Using templates

To base a page on a template first ensure that the template itself has been saved and closed – a page cannot be based on an open template.

Note All pages which KompoZer creates which are based on templates are created as HTML documents using the Transitional doctype. It is not possible to create XHTML documents or those with Strict doctypes from templates.

To create a page

  1. Click File > New > A new document based on a template > Choose File.
  2. Select the Template (Note templates have the file extension ‘mzt’)
  3. Click ‘Create’.

The page that appears carries

To use the page

Warning - At KompoZer 0.7.10 the text for repeatable items cannot be edited at this stage, however copies may be made for editing later.

  1. Click in turn in each editable areas.
  2. Page generated by using templateSelect and delete the sample text and replace it with new text.
    2a If the editable area was repeatable a small square appears within the label, hovering turns it red and clicking makes a copy. Copies have small circles which act as delete buttons. The third figure (above) illustrates the template with one flow item (the Changed areas) repeated once. The first three items have the text replaced.
    2b If any area was optional a small circle with an x appears within the label. Hovering turns it red and clicking deletes it. The same figure shows this for the 'Other languages'. Because of the limitation described it has not been possible to fill in all the editable areas.
  3. When all editable boxes have been completed detach the page from the template by clicking Edit > Detach from template. The page now assumes its final appearance.
  4. Save the page in the normal way. The last figure shows the final result. The areas which could not be edited earlier have been completed.

Now it is possible to edit any item and as a workaround the frozen repeatable items may be added.

7.7    Editing templates

Templates which have already been saved may be altered after opening using menu commands File > Open File and selecting ‘Files of Type’ then ‘HTML Templates’.

Note The default opening setting is ‘HTML Files’ which will not open templates.