Login Login



Wanted articles
Who is online?
Article tools

Help:Wiki Template

From osTicket

Revision as of 19:43, 29 April 2014 by Josh (Talk | contribs)

Jump to: navigation, search

Templates can be used to guide the structure of an entire page's content. They can also serve as inner-article templates (i.e., a single warning box with a message). Most templates that are created will use template parameters. These parameters represent text that the user must specify at the time of implementing the template, and those values will be placed in the article according to the defined locations in the template.

Making a Template

To create a template, you simply need to go to the url where your template will belong. All templates should belong to the Template Namespace. This means that your url will have Template: preceding the template name. So, if you want to create a Warning Box Template, you would go to wikisite.com/index.php?title=Template:Warning_Box to create your template. When the page loads, and you are prompted that no page exists, choose to create it to begin.

Defining Template Parameters

You must specify parameter names in every place of the template where you want user-defined content to appear. To create a new parameter, place its name in between three sets of curly brackets (e.g., {{{param_name}}}).

Default Parameter Values

If the user does not specify a value for a parameter, the parameter name will appear in the article that implements the template. If you would like to specify a different default value, use the following syntax in your template: default value here.

Using CSS & JS in Your Template

If you would like to create CSS classes to be used in your templates, you can edit MediaWiki:Common.css. Any changes made to this file will be applied to all MediaWiki skins.

If you would like to apply Javascript to any templates, you can add your javascript to MediaWiki:Common.js.

Implementing Your Templates

To implement any template into an article, in your article, simply enclose the template name in two sets of curly brackets where you want the template to appear (e.g., {{template_name}}).  The article name should be written here without the namespace identifier used in the URL (i.e., Template:). 

Defining Parameter Values

To define parameter values, use the following syntax: {{template_name | param_1=value goes here}}.

If you need to define the value for more than one parameter, you can write each parameter and its value on a single line. For example:

| param_1=''value goes here''
| param_1=''value goes here''
| param_1=''value goes here''

Placement of Templates in Articles

The transclusion of templates in articles is very versatile. The following is how they may be transcluded in articles:

  1. The template implementation does not need to be the only thing in an article. You may place as much content before and/or after a template implementation.
  2. You may implement more than one template in a single article.
  3. You may nest the transclusion of one template within another template in an article.

osTicket's Template Convention

For the sake of consistency, the following is required for the creation/editing of template pages used in osTicket's wiki software.

Required Notation

The notation required is beneficial when one of osTicket's authorized wiki editors is perusing through the Template namespace. When they open up one of the Templates, the page will display more than just a live example of the template. It will explain the purpose of the Template and how they might use it.

The Requirements:

  1. Live Demo. Give a live demo of the template.
  2. Designated Use. Explain what is the purpose and intention of the template.
  3. Source Code. Give the source code for the template so that it may be easily copy and pasted into the article that will implement it. To do this, simply place the code in a set of <pre></pre> tags.

How to...

Below you can learn how to satisfy the requirements for creating/editing templates for osTicket's wiki.

Include a Live Demo

This should be the first thing on a template's page. The live demo will display naturally because MediaWiki will parse it when the page is opened just like when it is transcluded.

Explain Use

Under a Wiki Heading 2, explain why the template was created and where it is intended to be implemented. If this template is to be nested within another template, include a link to that template's page. It is also encouraged, but not required, to describe where this might also be beneficial outside of the intended uses.

  • Write out the code that is necessary to implement the template and all of its parameters. For example, note the following:
| param1=value for param1 here
| param2=value for param2 here
  • In order to display the code in the browser, it is necessary to place the template code within a set of <pre></pre> tags.
  • Right above the <pre></pre> tags, include a Wiki Heading 2 labelled as Source Code.

Hide Notation and Source Code Upon Implementation

The most important part to remember is to wrap everything in a set of <noinclude></noinclude> tags that is in the template page that you do not want displayed when the template is implemented. In other words, the <noinclude></noinclude> tags must surround everything from the template's explanation header to the end of the Source Code.