FANDOM


What you need to know to get started with MediaWiki Templates


  1. Create the template
        1. How to create the template page
           There are two ways of creating a new template page.
           The first is to edit or create a page and type in: Template:Some template name. Enlosing the template name in double curly brackets is what defines the template name.
           Save the page.
           This will create a link to an empty page that will be your template page. Your newly saved page will say "Template:Some template name" (which is the link).
           Clicking on the link will launch you into editing the template page.
           The other way to create a new template page is to go to a URL that lets you define a new template page.
           For example, if you type into your web browser http://<your mediawiki here>/index.php/Template:Yet Another Template and hit the Go button, you will be taken to a page called "Template:Yet Another Template"
           There will be a note on that page that says "(There is currently no text in this page)"
           You can of course click on "edit this page".
           The example template page I chose to create was Template:Biography.
           So I had my choice of a URL http://<your mediawiki here>/index.php/Template:Biography or I could create a new page and type into it Template:Biography
        2. What should be in the template page
           The template page should be a regular MediaWiki page, with the exception that it will have replaceable field names embedded in it.
           These field names are surrounded by three curly brackets.
           For example, the template page could be as simple as:
           This page will display the name of a tiger here: {{{tigername}}}
        3. Editing the template page
           Editing the template page is a tiny bit tricky. Remember how one of the ways to create a new template page was to reference it by URL? That is the easiest way to edit it.
           Use the URL that specifies the template, view that page. Then edit that page.
           Otherwise, it can be hard to find the original template, to edit it.
           After saving the page, MediaWiki will display the template with {Template:field name}
           Don't freak out about the references to templates in there. We can safely ignore them.
  2. Using the template
        1. Edit or create a new page
           Just like normal.
        2. What to type to invoke the page
           The way to invoke a template is to enclose the template name within two curly brackets.
           If the template uses replaceable fields, they have to be piped into the command that invokes the template. In other words, the curly brackets enclose the template name, and the data.
           To simply include a template, you would type this: Template:Some template name
           To include a template with replaceable parameters, you would type this: Template:Yet Another Template
           Nicely enough, in the template specifier line, if the last character is a pipe character ("|"), then you can separate the fields on individual lines.
           Because we are using fieldnames inside our template, we can add an extra pipe character, and it does not throw things off.
  3. Examples implementing a "Biography"
     This section contains:
        1. The text of my Template:Biograpy page
        2. The text in the page that calls the Biograpy template
        3. The page output
        1. Biography template
           This is a biography for {{{name}}}.
           This person was born on {{{birthday}}} at {{{birthplace}}}.
           This person's father was {{{father}}}. This person's mother was {{{mother}}}.
           This person's primary language is {{{language}}}.
           This person's motto is "{{{motto}}}".
        2. Biography data page
           Template:Biography
        3. Biography result
           This is a biography for David Gerisch.
           This person was born on 1900's-January-Thereabouts at Northernish, CA, USA.
           This person's father was Richard Gerisch. This person's mother was Patricia Gerisch.
           This person's primary language is English.
           This person's motto is "The difficulty of Libertarianism: not 'I must be free' but 'That other jerk must be free, as well'".

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.