Sunday, 27 December 2020 14:03

Template Manager

 Create and insert snippets of HTML content
About the Template Manager
Template Manager Interface
Creating a Template
Template Manager Configuration
 

The Template Manager creates and inserts templates - custom html files that contain content for inserting into articles, often text or html that you use frequantly like disclaimers, copyright notices or structured html content to build articles on like layouts, tables etc.

Templates can be created either by saving an articles html content to a file, or by creating the template (an html file) in an HTML editor. For more information on creating templates see Creating a Template.

The Template Manager is not a plugin to create or edit Joomla! Templates

The Template Manager, like the other Manager plugins, uses the familiar Manager Interface, but unlike the other Manager plugins, does not have an Attributes section - templates don't have attributes!

The Template Manager has one unique button, the  New Template button, used to create new templates from the current article content. See Creating a Template

Template manager interface

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

  • Name - The name of the template
  • Type - The type of 'template' to create, either a Template or a Snippet

Template wraps your content in a div with a unique id, which allows it to be identified.
Templates can be replaced by other Templates or Snippets using the Template Manager.

Templates can have predefined variables in its content replaced by values defined in the Template Manager configuration - see Template Manager Configuration.

Unlike Snippets, which can only be inserted into the article content at the current cursor position, Templates can affect selected contentThe selected article content 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>

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> 

Snippet is a chunk of html code. It is not editable / replaceable as Templates are, but can have predefined variables in its content replaced by values defined in the Template Manager configuration - see Template Manager Configuration.

Snippets will replace selected content.

Example of Snippet html:

This is just some code

Template Manager options are set in the Plugin Parameters tab in Editor Profiles

Standard Parameters

File Directory Path

This is an optional value to set the path to use for the Template Manager. If left blank, the value in the Editor Parameters Filesystem section is used.

Upload File Size

An optional value for the maxiumum file size allowed when uploading. If left blank, the value in the Editor Parameters Filesystem section is used.

Permitted File Extensions

Set the file types that the Template Manager can upload and display. The default types are htm, html, txt.

Filesystem

Set the Filesystem to use for the Template Manager. Leave unselected to use the filesystem set in the Editor Parameters Filesystem section.

Advanced Parameters

Startup Content

Select an html, htm or txt file to load into the editor when a new article is created.

Replacement Values

This is a comma seperated list of key/value pairs, where the key is a classname or variable in the template html and the value is the replacement for this variable. Example:

username:"Joe Blogs",staffid:"991234"

Using the above replacement values, the variable {$username} in the template html will be replaced with the value 'Joe Blogs', or any tag with the class name 'username' will have the value 'Joe Blogs' inserted into it. Example:

The html Username : {$username} will become Username : Joe Blogs

Content Classes

This is a list of class names, seperated by spaces, used by Templates. When article content is selected and a Template applied, any html within the Template that contains one of these classes, will be applied to the selected content. Example:

selcontent selectedcontent selected

Creation Date Classes

A list of class names separated by spaces. Any Template with one of the classes will have its content replaced by the 'creation' date, formatted according to the Creation Date Format option. A creation date is one that is set if no previous date existed within the element. Once set the original date is stored inside the element in a HTML comment and is designed not to change even with a template change. Example:

cdate creationdate

Modified Date Classes

A list of class names separated by spaces. Any Template with one of the classes will have its content replaced by the 'modified' date, formatted according to the Modified Date Format option. A modified date is one that is updated with each edit. Example:

mdate modifieddate

Creation Date Format

A date format string for the creation date. Example:

%m/%d/%Y : %H:%M:%S

Modified Date Format

A date format string for the modified date. Example:

%m/%d/%Y : %H:%M:%S

Permissions

Set whether the Template Manager can allow uploading, folder creation, folder/file deleting and renaming and file cut/copy/paste options.

 
Read 8248 times Last modified on Sunday, 27 December 2020 14:11
More in this category: « IFrames Microdata »