From WikiTemp, the GBAtemp wiki
 
(6 intermediate revisions by one other user not shown)
Line 15: Line 15:
 
::Thank you for your answer, I'll read it. --[[User:Cyan|Cyan]] 14:14, 5 March 2007 (CET)
 
::Thank you for your answer, I'll read it. --[[User:Cyan|Cyan]] 14:14, 5 March 2007 (CET)
  
:::The compatibility list is a bad example, simply because it is using custom extensions. Mythril is on the money though. Triple {} brackets means a user-specified parameter that will be passed to the template, and double {} brackets are what you use to call the template. An easy to understand example would be [http://wiki.gbatemp.net/index.php?title=0434_-_NEW_Super_Mario_Bros._%28U%29&action=edit this page]. It uses 3 simple templates (which have links at the bottom of the page). Parameters are not required to be numbered either, it just makes it easier when calling the template. For example they could be called {{{hello this is a parameter}}} or {{{blah}}}, but to call the template you'd have to insert something along the lines of:
+
:::The compatibility list is a bad example, simply because it is using some quite complex custom extensions. Mythril is on the money though. Triple {} brackets means a user-specified parameter that will be passed to the template, and double {} brackets are what you use to call the template. An easy to understand example would be [http://wiki.gbatemp.net/index.php?title=0434_-_NEW_Super_Mario_Bros._%28U%29&action=edit this page]. It uses 3 simple templates (which have links at the bottom of the page).  
 +
:::Note that parameters are not required to be numbered, it just makes it easier when calling the template. For example they could be called {{{hello this is a parameter}}} or {{{blah}}}, but to call the template you'd have to insert something along the lines of:
 
:::<pre>{{template name|hello this is a parameter=what user sees for this parameter|blah=what user sees for this parameter}}</pre>
 
:::<pre>{{template name|hello this is a parameter=what user sees for this parameter|blah=what user sees for this parameter}}</pre>
 
:::[http://www.mediawiki.org/wiki/Help:Templates This page] explains templates very nicely (and supersedes the link posted further up the page) [[User:Dirtie|Dirtie]] 11:10, 6 March 2007 (CET)
 
:::[http://www.mediawiki.org/wiki/Help:Templates This page] explains templates very nicely (and supersedes the link posted further up the page) [[User:Dirtie|Dirtie]] 11:10, 6 March 2007 (CET)
 +
 +
:::Edit: I forgot to mention that the subst: command substitutes the contents of the template into the page directly when it is saved.
 +
:::So let's say we had a simple template named "Template:simple" consisting of:
 +
:::<pre>Contents of template, an {{{1}}}</pre>
 +
:::Then we put the following into a page:
 +
:::<pre>{{subst:simple|example}}</pre>
 +
:::If we saved the page and took a look at the source, we'd see it had changed into:
 +
:::<pre>Contents of template, an example</pre>
 +
:::It's useful if you do not want the page to change dynamically whenever the template is modified (but can make pages messy or unnecessarily long)
 +
 +
:: Thank you Dirtie. I found the mediawiki link on wikipedia yesterday, it was very helpfull and easy to understand.  It will help other users too.
 +
:: I think for NDS list, it's an additional script that check the data and replace it with javascript. I just wanted to understand how the process worked before editing anything. --[[User:Cyan|Cyan]] 12:13, 6 March 2007 (CET)

Latest revision as of 11:13, 6 March 2007

Templates

Hi, maybe it's only for admin to use it, but I would like a tutorial on how to create and use a template. I know the {{template name}} thing, for simple template like {{List Ranges}} it's easy to understand and use.

But I don't know how it can change an article's data with complexe template. For exemple the NDS compatibility template {{Slot-1 Compatibility}} use {{{1}}}, {{{2}}}. Is that a mask for data written by a user, so if you change the template the data filled by a user is left as is ? What the subst: stand for ?

Maybe you are still testing it because I didn't see this template in the NDS compatibility list article.

--Cyan 13:22, 5 March 2007 (CET)

The Wikimedia's help page about templates might be of help. But I guess having a short description in GBAtemp's wiki wouldn't hurt either.
Anyway, {{{1}}} means the first parameter given to the template, {{{2}}} means the second parameter, etc. So if you call the template like this {{Template|parameter1|parameter2}}, {{{1}}} will be replaced with parameter1, and {{{2}}} is replaced with parameter2. Don't remember what subst: is though... --Mythril 13:54, 5 March 2007 (CET)
Thank you for your answer, I'll read it. --Cyan 14:14, 5 March 2007 (CET)
The compatibility list is a bad example, simply because it is using some quite complex custom extensions. Mythril is on the money though. Triple {} brackets means a user-specified parameter that will be passed to the template, and double {} brackets are what you use to call the template. An easy to understand example would be this page. It uses 3 simple templates (which have links at the bottom of the page).
Note that parameters are not required to be numbered, it just makes it easier when calling the template. For example they could be called {{{hello this is a parameter}}} or {{{blah}}}, but to call the template you'd have to insert something along the lines of:
{{template name|hello this is a parameter=what user sees for this parameter|blah=what user sees for this parameter}}
This page explains templates very nicely (and supersedes the link posted further up the page) Dirtie 11:10, 6 March 2007 (CET)
Edit: I forgot to mention that the subst: command substitutes the contents of the template into the page directly when it is saved.
So let's say we had a simple template named "Template:simple" consisting of:
Contents of template, an {{{1}}}
Then we put the following into a page:
{{subst:simple|example}}
If we saved the page and took a look at the source, we'd see it had changed into:
Contents of template, an example
It's useful if you do not want the page to change dynamically whenever the template is modified (but can make pages messy or unnecessarily long)
Thank you Dirtie. I found the mediawiki link on wikipedia yesterday, it was very helpfull and easy to understand. It will help other users too.
I think for NDS list, it's an additional script that check the data and replace it with javascript. I just wanted to understand how the process worked before editing anything. --Cyan 12:13, 6 March 2007 (CET)