Help:Templates
If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play.
Creation
Templates are standard wiki pages whose content is designed to be transcluded (embedded) inside other pages. Templates follow a convention that the name is prefixed with "Template:
", assigning it to that namespace; besides this, you can create them like any other wiki page.
The simplest use of templates is as follows. If you create a page called "Template:Welcome" with contents:
Hello! Welcome to the wiki.
you'll have created your first template! If you then insert the code:
{{Welcome}}
in any other page, when that page is viewed the text "Hello! Welcome to the wiki." will appear instead of {{Welcome}}
. The template content is "transcluded" into the other page, i.e. it is integrated in the page.
You can then insert {{Welcome}}
at any point of any page where you wish to welcome someone. Suppose it is used in 100 pages. If you then change the template contents to:
Hi there! Welcome to this wonderful wiki.
and revisit any of the 100 pages where the template was used, you'll see the new text instead of the original one. In this way, you have changed the content of 100 pages without editing them, because the template is transcluded into these pages.
This is the basic mechanism. There are several additional features of transclusion that enrich this mechanism and make templates very useful.
Usage
Templates can be used in other pages in these ways:
{{Name}}
— as described above, this link will be dynamically replaced by the current content of [[Template:Name]] at the time the page with the template link is loaded. The link will remain unchanged in the page's source.{{subst:Name}}
— when this template link is used, it will be replaced once and for all with the content of [[Template:Name]] as of the time the page with the link is saved: a copy of the contents of [[Template:Name]] will be substituted for the template link. The contents are then a part of the including page, and can be edited normally, separately from the original. Note: changes to the source template page will not be propagated to the page with the template link.{{safesubst:Name}}
— this was introduced in rev:61710 to allow for substitution that doesn't break transclusion, see w:en:Help:Substitution#The safesubst: modifier.{{msgnw:Name}}
includes the template in a form that displays it as raw wiki syntax (the way<nowiki>
does) when the page containing it is fetched.
List of Templates available for use
For a list of available templates, click here http://karnatakaeducation.org.in/KOER/en/index.php/Special:UncategorizedTemplates