The master template

To add a new template, you have to create a new plain "Text" file in the templates subfolder of an existing module, e.g. the folder /system/modules/com.alkacon.documentation.howto-template/templates/. This text file is called the "master template". 

All master templates must be placed in the templates subfolder of a module. If a user creates a new page in OpenCms, he can select a template from all available master templates. The title property of the master template will be displayed in the template selector of the "new page" dialog (e.g. "Alkacon documentation howto simple template").

The following example of a master template is taken from the file /system/modules/com.alkacon.documentation.howto-template/templates/howto and should be used as a model pattern for your own templates:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- This links the XMLTemplate mechanism with the JSP templates.
     So far it is required because the WYSIWYG editor still is
     completly based on the XMLTemplates. -->
<xmltemplate>

<!-- Define the stylesheet for the WYSIWYG editor -->
<stylesheet>/system/modules/com.alkacon.documentation.howto-template/resources/mystyle.css</stylesheet>

<!-- Template description, pretty short for a JSP template -->
<template>
	<element name="jsptemplate"/>
</template>

<!-- This describes the "jsptemplate" element used above.
     Important: The element must NOT be called "frametemplate",
     because in that case the stylesheet does not work. -->
<elementdef name="jsptemplate">
	<!-- Always use this class tag when inserting a JSP element in your page: -->
    <class>com.opencms.flex.CmsJspTemplate</class>   
    <!-- Just add the path to your JSP here: -->
    <template>../jsptemplates/howto.jsp</template>
</elementdef>
    
</xmltemplate>

The master template uses the OpenCms XMLTemplate syntax. Currently this a requirement, but this might change in a future release.

For your own templates you need not to bother about the XMLTemplate syntax, you only have to change three things:

Bottom line: To create your own master template, copy this example, change the path values of the <stylesheet> , the <elementdef name="jsptemplate"> and the "title" property.

In step 2 you will now learn how to create a simple JSP template.

]]>