MediaWiki/Templates

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 &#123;&#123;Template:Welcome&#125;&#125; into another page to use template

Parameters
Three curly braces: Hello &#123;&#123;&#123;1&#125;&#125;&#125; &#123;&#123;&#123;2&#125;&#125;&#125;

To pass a parameter: &#123;&#123;Template:Welcome|Joe|Smith&#125;&#125; &#123;&#123;Template:Welcome|2=Smith|1=Joe|&#125;&#125;
 * 1) anonymous
 * 1) numbered

Named parameters: Hello &#123;&#123;&#123;fname&#125;&#125;&#125; &#123;&#123;&#123;lname&#125;&#125;&#125;

To pass named parameter: &#123;&#123;Template:Welcome|lname=Smith|fname=Joe|&#125;&#125;

Default parameters: Hello &#123;&#123;&#123;fname|Mr&#125;&#125;&#125; &#123;&#123;&#123;lname|Unknown&#125;&#125;&#125;

Control
Hide things like categories: &lt;noinclude&gt;...&lt;/noinclude&gt;

Only show this on inclusion (save as above but opposite) &lt;includeonly&gt;...&lt;/includeonly&gt;

Find Templates
To find them, users can:
 * 1) Click Special pages > All pages
 * 2) In the Namespace: list, choose Template and click Go.