No categories assigned

Templates

Revision as of 15:05, 28 October 2019 by Mlink-rodrigue (talk | contribs) (Changed categories.)

What are templates?

Templates contain (source-)code, that can be included at different places of the wiki. On the one hand, it makes sense to outsource frequently used components such as letter templates or checklists so that they do not have to be recreated each time. Templates can also ensure some amount of consistency regarding content structure and styling. In addition, the use of templates offers some flexibility, as changes can be made centrally and affect all pages that access the template. Accordingly, possible applications for templates are the management of messages, the creation of uniform navigation areas or simply the unification of a group of pages.

Creating new templates

A new template is created like an article page, only in the namespace template.

Example: The whole page name of the template MyTemplate is Template:MyTemplate.

Hint: Please note that the names of templates are case-sensitive.


Usage of existing templates

You can use a template on a wiki page by putting the template name (without the namespace name) in double curly brackets:

{{MyTemplate}}

Such use causes the bracketed text to be replaced by the source text of the template when the page being used is accessed. The source code of the using page still contains the bracketed text, so that future changes to the template will also affect existing uses of the template. The source code of the template can also be generated when the page is saved instead of when the page is called. The following form is used for this:

{{subst:MyTemplate}}

This can be useful if you want to create an initial text that can later be changed on each new page.

The namespace "Template:" is reserved for templates. All pages in this namespace are considered templates, but not all of them may be relevant to every article author. A complete list of pages in that namespace can be seen on special page of the namespace Template.


Editing existing templates

Before existing templates are significantly changed, the project should be briefly discussed or announced on the discussion page of the respective template.


Built-in variables

Each MediaWiki has a number of Built-in Variables that are not pages in the "Template:" namespace, but are still used as templates.

The variable {{CURRENTTIME}} (current UTC time) for example returns the value 21:07.

Further notes

  • The use of templates is basically a Transclusion. It is also possible to use pages that are not in the corresponding namespace as templates. However, this is to be done with caution, since some functions require that the pages are located in the template namespace.
  • Templates can also be used to define the output of semantic queries. More information can be found here. (This is an example where the pages must be in the template namespace.)


Templates in BlueSpice

Internal links

Externe Links

Attachments

Discussions