Welcome to the Virtual Education Wiki ~ Open Education Wiki

Help:Templates

From Virtual Education Wiki
Jump to navigation Jump to search

Text help

If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play.

Unlike extensions and media files, there is no central repository for templates. Templates can be newly written or to save duplicating work already done, exported from another wiki e.g. Wikipedia, and then imported into the target wiki.


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 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.

For futher reading see the page Help:Templates on the wiki www.mediawiki.org.


Video resources

  1. See the YouTube video Infoboxes and an introduction to forms – Tutorial 13 (2021)

> Help:Index