A topic content template is an XML file containing the "framework" of a topic – it is used to create topics with repetitive content, for example identical tables and headings and so on.
Topic content templates can contain everything that a topic can contain, including tables, formatted text, graphics, links and so on. You can create as many content templates as you like and load them with you create topics with standard layout that you use repeatedly. You can also create content templates that are loaded automatically when you create new topics.
1.Create a new topic. The topic ID is irrelevant because you are going to delete the topic as soon as you have saved the template.
2.Edit the topic and add everything that you want to have in the template. You can use all the features that you can use in a normal topic, including tables, graphics, formatted text, hyperlinks and so on.
3.Enter the topic header (in the area above the editor, not in the TOC) exactly as you want it to appear in the topic. See the instructions below for automatically inserting the TOC caption in the header.
4.Select File > Save Topic to File in and save the topic as an XML file in the project folder, using the following naming syntax:
filename.template.xml
The .template. part of the name is essential, it identifies the XML file as a template. Templates must be stored in the current project directory and must use this naming syntax. If you call the template default.template.xml it will be selected automatically for new topics (see further below for details).
Examples:
intro.template.xml
functiondocs.template.xml
standarddocs.template.xml
default.template.xml (will be autoselected for new topics)
5.Delete the topic you have just created if you don't want to use it in your project now. |
To create a new topic with a template:
1.Choose one of the Add Topic options in the tab to create a new topic.
2.Select the template in the Topic Template: field of the Insert New Topic or Chapter dialog.
Note that the template will only appear in the Topic Template: field for selection if it is stored in your project directory using the filename.template.xml naming syntax (see above for details).
To load a template into an empty topic:
1.Create an empty topic.
2.Select File > Load Topic from File in and select the template file you want to load.
Don't try to load a template into an existing topic, this will overwrite the entire contents of the topic!
|
When you create topic templates to use for creating new topics you can include a special variable in the header that will automatically insert the topic caption (the title of the topic you enter in the Add Topic dialog) in the header of the topic. If you don't use this variable the template will be loaded with the header saved with the topic.
You also need to insert this variable in the Title Tag: field in the Topic Options tab on the left of the editor window so that the header text of your topic is used there as well – otherwise the header text stored with the content template file will be used.
1.Delete the header of the template topic (in the area above the editor, not in the TOC) and replace it with the following variable:
%TEXT%
2.Type in the variable manually exactly as shown, using all upper case. Only enter % and % before and after the variable name. This is the only variable that does not use <% and %> tags.
You can also include other text and elements in the header, including graphics. Only the variable is replaced when a new topic is created.
3.Select the Topic Options tab on the left of the editor window and type the same %TEXT% variable in the <TITLE> Tag: field:
This variable only works when you create a new topic with a content template file. The %TEXT% variable is not translated when you load the template into a empty topic with File > Load Topic from File in
|
In addition to templates that you can select manually for new topics you can also create a topic content template with a special name that will get selected automatically for every new topic. Just follow the instructions above for creating topic templates and save the template in your project folder (the same folder where your .hmxp or .hmxz project file is stored) with the following name:
default.template.xml
If this template exists in your project folder it will be preselected automatically when you create a new topic. If you want to change it you can still select a different template from the list in the new topic dialog. Otherwise clicking on OK will create the new topic with the standard template.
|
If you frequently use topics with different standard styles you could create a separate template for topics with each set of styles already preset in the topic header and body. Then you just need to select the appropriate template when you create a new topic (see above).
|
See also:
Creating new topics
Exporting and importing topics