Creating a Template

The Template Manager is able to create new templates from existing content, that is, the contents of the article you are editing/creating when the Template Manager is open.

A template can be created from a selection or from the whole article. When just a selection is required, you must select the desired content before opening the Template Manager. This is not necessary if you are using the whole article.

Creating a Template

Once the Template Manager plugin dialog is open, click the New Template icon. The Create Template dialog will open.

Create template

Set a name for the template and click the Create button.

If the Text Editor option is enabled in the Template Manager Configuration, the New Template button will open a Text Editor, prefilled with the article content if any. Similar to the Code Editor, the Text Editor can be used to create and edit HTML, JSON and plain text content, and saved to a file.

Templates can have predefined variables in the content replaced by values defined in the Template Manager configuration - see Template Manager Configuration. These can be used to update or style a content selection, set or update a Date and Time value, or replace a variable in the content - set in the template using the syntax {$name} - using a predefined value.

Updating a content selection

Any content selected in an article when the template is inserted will be altered by whatever html is contained in the Template that has a class included in the Content Classes' list in the Template Manager Configuration. For example, selected content will be given a yellow background by the following html in the Template:

<p class="selcontent" style="background-color: yellow;">Selected Content</p>

If the template does not contain a Content Class then the selection will be replaced with the inserted template content.

Dynamic Date Values

Templates can also trigger Creation Date and Modified Date parameters defined in their content. For example, if a Template contains a <span> tag with a class of cdate, creationdate, or any one of the classes specified in the Template Manager Configuration, this <span> tag will have the current time and date inserted into it when the Template is inserted into the article content, eg:

<span class="cdate"></span> 

will become

09/17/2007 09:05:54

The time and date format is editable in the Template Manager Configuration

The creation date is only set once, when the Template is first inserted, but the Modified Date will change whenever the article is modified.

Example of Template html

<div class="mceTmpl">
<p class="selcontent" style="background-color: yellow;">Selected Content</p>
<p style="padding: 3px; color: #666; border: 1px solid #CCC;"><br /><strong>Editors Comment</strong> (<span class="cdate"> </span>)<br /><br />[Insert your comment here]</p>
</div>  

The Template above applied to this text:

Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

becomes:

<p class="selcontent mceTmplElm mceSelHTMLDone" style="background-color: yellow;">Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p class="mceTmplElm" style="border: 1px solid #cccccc; padding: 3px; color: #666666;"><strong>Editors Comment</strong> (<span class="cdate mceTmplElm">09/17/2007 : 11:28:39 </span>)<br class="mceTmplElm" /> [Insert your comment here]</p>