MediaWiki/Templates

From Omnia
Revision as of 04:51, 15 March 2016 by Kenneth (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Templates

Help:Templates - MediaWiki - http://www.mediawiki.org/wiki/Help:Templates

Create

"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:

1. Create a page called "Template:Welcome"

2. Insert some text into this new page

3. Insert {{Template:Welcome}} into another page to use template

Parameters

Three curly braces:

Hello {{{1}}} {{{2}}}

To pass a parameter:

# anonymous
{{Template:Welcome|Joe|Smith}}
# numbered
{{Template:Welcome|2=Smith|1=Joe|}}

Named parameters:

Hello {{{fname}}} {{{lname}}}

To pass named parameter:

{{Template:Welcome|lname=Smith|fname=Joe|}}

Default parameters:

Hello {{{fname|Mr}}} {{{lname|Unknown}}}

Control

Hide things like categories:

<noinclude>...</noinclude>

Only show this on inclusion (save as above but opposite)

<includeonly>...</includeonly>

Find Templates

To find them, users can:

  1. Click Special pages > All pages
  2. In the Namespace: list, choose Template and click Go.