Help:Templates: Difference between revisions

no edit summary
(remove old stuff)
No edit summary
Line 1: Line 1:
A '''template''' is a pre-set piece of text that can be added to a page without having to retype the same text over and over again.   This presents an advantage as you only have to change the text on one page and the change will be reflected on every page that contains the template.
A '''template''' is a pre-set piece of text that can be added to a page without having to retype the same text over and over again. This presents an advantage as you only have to change the text on one page and the change will be reflected on every page that contains the template.


==Example==
==Example==
The template <nowiki>{{Flood}}</nowiki> as shown below can be added to every single page that talks about the [[Flood]].   This allows the user to jump to other Flood Forms and if another Flood form is discovered then only one file, the Flood template file, needs to be edited.
The template <nowiki>{{Flood}}</nowiki> as shown below can be added to every single page that talks about the [[Flood]]. This allows the user to jump to other Flood Forms and if another Flood form is discovered then only one file, the Flood template file, needs to be edited.


{{Flood}}
{{Flood}}
Line 12: Line 12:


==To Insert a Template==
==To Insert a Template==
To insert a template,  all templates are displayed [[:Category:Templates|on this page]]. The code that inserts a template into an article is always between double curly brackets - <nowiki>{{Insert Template Name Here}}</nowiki>. ex. <nowiki>{{Flood}}</nowiki>
To insert a template,  all templates are displayed [[:Category:Templates|on this page]]. The code that inserts a template into an article is always between double curly brackets: <nowiki>{{Insert Template Name Here}}</nowiki>. Example: <nowiki>{{Flood}}</nowiki>


==Creating a Template==
==Creating a Template==
If you feel a need for a template and want to create your own to add to pages then you can create your own. First search that your idea for a template doesn't already exist.   Then type "Template: Template Name Here into the search box.  The Search should come up empty with an option to create your own article with the search phrase.   Create the Template, save and then add the template by using instructions above.
If you feel a need for a template and want to create your own to add to pages then you can create your own. First search that your idea for a template doesn't already exist. Then type "Template:Template Name Here into the search box.  The Search should come up empty with an option to create your own article with the search phrase. Create the Template, save and then add the template by using instructions above.


==Editing a Template==
==Editing a Template==
Before you edit a template be wary of your changes as they will be reflected across many, in the some case dozens of pages. To edit a Template you just type in the search box "Template:Template Name Here". For example to edit the Flood Template type "Template:Flood" in the search box.
Before you edit a template be wary of your changes as they will be reflected across many, in the some case dozens of pages. To edit a Template you just type in the search box "Template:Template Name Here". For example, to edit the Flood Template, type "Template:Flood" in the search box.


==Advanced Templates==
==Advanced Templates==
Templates can also be custom built for each page that they're used. A good example is a template where every time a template is used, it adds who added it, when, and why. A template can do this by asking for those three "parameters" or values from the template.
Templates can also be custom built for each page that they're used. A good example is a template where every time a template is used, it adds who added it, when, and why. A template can do this by asking for those three "parameters" or values from the template.


===Make your own===
===Make your own===
You can get your template to ask for information simply by adding this code <nowiki>{{{1}}}</nowiki> in your template.  By adding the <nowiki>{{{1}}}</nowiki> the template knows to put whatever is passed first in place of the <nowiki>{{{1}}}</nowiki>.   To add other values/variables/parameters just increase the number i.e. <nowiki>{{{2}}}</nowiki><nowiki>{{{3}}</nowiki>
You can get your template to ask for information simply by adding this code <nowiki>{{{1}}}</nowiki> in your template.  By adding the <nowiki>{{{1}}}</nowiki> the template knows to put whatever is passed first in place of the <nowiki>{{{1}}}</nowiki>. To add other values/variables/parameters just increase the number, i.e. <nowiki>{{{2}}}</nowiki> <nowiki>{{{3}}</nowiki>.


Here is some of the code from an outdated template. See how the <nowiki>{{{1}}}</nowiki> are placed where the parameters are supposed to go:
Here is some of the code from an outdated template. See how the <nowiki>{{{#}}}</nowiki>'s are placed where the parameters are supposed to go:


<pre>
<pre>
Line 44: Line 44:


===Naming the Parameters===
===Naming the Parameters===
You can take this a step further by instead of using a number you name the variable. A good example of a template that uses this method is the ''Infobox [[xbox live]] settings'' template:
You can take this a step further by instead of using a number you name the variable. A good example of a template that uses this method is the ''Infobox [[xbox live]] settings'' template:


For the "Infobox xbox live settings" template you insert this code and then fill in the appropriate data.
For the "Infobox xbox live settings" template you insert this code and then fill in the appropriate data.