This page has some helpful notes for my own use =).
General Notes (Click "Show" to view)
General Notes
[[#Section name]] Links to another section on the same page.
[[Page name#Section name]] Links to a section of a page. Matches must be exact in spelling, case, and punctuation. If you link to a non-existent section, it will just take you to the top of the page.
Redirecting - put this on the first line of the article.
#REDIRECT [[Page name you want to redirect to]]
#REDIRECT [[Page name#section name]]
Images
Float right:
[[Image:imagename.png|frame|text to display under it]]
OR
[[Image:wiki.png|thumb|Wikipedia Encyclopedia]]
Resize:
[[Image:wiki.png|30 px]]
<u></u> underline
<s></s> strike through
<!-- comment here -->
To comment on a page for future editors
Variables
Code Effect
{{CURRENTWEEK}} 33
{{CURRENTDOW}} 4
{{CURRENTMONTH}} 08
{{CURRENTMONTHNAME}} August
{{CURRENTMONTHNAMEGEN}} August
{{CURRENTDAY}} 13
{{CURRENTDAYNAME}} Thursday
{{CURRENTYEAR}} 2009
{{CURRENTTIME}} 14:00
{{NUMBEROFARTICLES}} 15,770
{{NUMBEROFUSERS}} 342,569
{{PAGENAME}} How to edit a page
{{NAMESPACE}}
{{REVISIONID}} 760062
{{localurl:pagename}} /wiki/Pagename
vhttp://www.wikipedia.org/wiki/Sandbox?action=edit</nowiki> http://en.wikipedia.org/wiki/Sandbox?action=edit
{{fullurl:pagename}} http://meta.wikimedia.org/wiki/Pagename
{{fullurl:pagename|query_string}} http://meta.wikimedia.org/w/index.php?title=Pagename&query_string
{{SERVER}} http://meta.wikimedia.org
Lists
#One
#Two
##Two point one
- Three
*One
*Two
**Two point one
*Three
From Wikipedia's Help:Template (Click "Show" to view)
From Wikipedia's Help:Template (Using and Constructing Templates in Mediawiki)
Template
- A page created explicitly for transclusion - the MediaWiki process of including the contents of 1 page within another page.
- Any page can be transcluded, but templates are designed specifically for that purpose, usually for repetitive material that might need to show up on lots of different pages. Commonly used for boilerplate messages, standard warnings/notices, infoboxes, etc.
- Templates may contain plain text, wikitext, HTML &/or CSS, or even other templates, & they have some limited programming capacities: customizable values (called parameters), calculation & branchings (using parser functions), & access to wiki-specific variables (magic words), like dates, times, & page names.
- Template names are just like other page names: case sensitive for the first letter, with spaces indistinguishable from underscores. The 1 exception is the use of number sign in links - #; in transclusion the number sign, & any characters that follow it, are ignored (rather than taking you to a section).
- To transclude a template into another page, use the following syntax (called a template tag): {{ template name | parameter | parameter | ... }}
This consists of the template name & various parameters that are passed to the template, where each parameter is separated by a vertical bar (or pipe), & the entirety is surrounded by doubled "". Not all templates have parameters, and not all templates that have parameters need to have values provided, so sometimes {{ template name }} is sufficient to use a template. If a parameter is needed, but a value not provided by the user, the template may render with something like {{{...}}} in the text, where the '...' might be a number or parameter name. This is to inform you that a named or unnamed parameter is missing, & can be avoided by using default values for the parameter.
- Parameters come in two basic forms:
- unnamed parameters: values that are put into the template in the order they appear: {{ template name|parameter1|parameter2|...}}
- named parameters: values associated with a particular named key in the template: {{ template name | parametername1 = parameter1 | parametername2 = parameter2 | ... }}
- These may be mixed: {{ template name |parameter1|parameter2| parametername1 = parameter3 | parametername2 = parameter4 | ... }}
- By convention named parameters are listed last, though that's not a requirement.
- Whitespace characters (spaces, tabs, returns) are stripped from the beginnings & ends of named parameter values (unnamed parameters are unaffected), but not from the middle.
Substitution
Generally, templates are processed into readable text when you browse a page. This is the normal intention of a template: since the template is reevaluated each time it's used, changes to the template can propagate across many pages quickly & effortlessly. Occasionally, however, this is not appropriate. Eg, a user may want a template which returns a date or time that remains fixed, rather than changing each time the page is browsed. For those cases there is substitution, which is done by adding subst: before the template name in the template tag. substitution does exactly what its name suggests: rather than processing the template each time the page is browsed, substitution processes the template at the time the edit is saved, & replaces the template tag with the processed results.
In general, substitution processes one level, so if the template in question contains other template tags, those template tags will be substituted in, rather than the processed results of those tags. This is a sometimes useful trick when debugging complex templates.
Other Usage Information
- To quote a template, creating a link to the template rather than actually invoking the template, use the "{{tl}}" template (the template link template). For example, using the text "{{tl|tc}}" creates a link to Template:Tc without actually doing what the template normally does.
- Templates may seem small compared to other pages on Wikimedia, but editing them can consume a tremendously disproportionate amount of system resources, particularly when they are transcluded onto large numbers of pages. When a change is made to a template, the MediaWiki software automatically places every page in which the template is transcluded onto the job queue to update the template links and ensure that any new page views will reflect the change. For very popular templates, it is better to create a copy in user space, make & test any needed changes there, present it on the template talk page to make sure there are no objections, & then introduce it as a single edit.
Creating & Editing Templates (Click "Show" to view)
Creating & Editing Templates
Anything that can be included on a normal page or article can be included on a template, including other templates (though as a practical matter templates will often have relatively small contents). Beyond that, templates have access to programming features - parameters, parser functions, & magic words - which allow for context dependent use,[2] & special tags that help control which info is transcluded & which isn't.
When creating templates, it's best to follow a few simple principles:
- Choose a short, descriptive name. Some people suggest that template names be completely small caps, some that spaces in template names should be avoided, but there's currently no hard guideline.
- Make sure your template is properly documented and included in the correct categories. Categorizing your template and documenting it will make it easier for other editors to find & use.
- To add documentation, put the {{documentation}} template inside 'noinclude' tags on the template page. This will create a documentation subpage that you can edit
- Categories that apply to the template itself should be added to the template page (inside 'noinclude' tags, with the {{documentation}} template). Categories that are to be transcluded to the transclusion page should be placed on the template page inside 'includeonly' tags.
- Try to make your template modular: i.e. capable of standing on its own & in a variety of different page contexts, without breaking, producing poor output, or messing up a page's layout. In general, you want your template to be transparently useful to other editors - the more effort they have to put into understanding how your template is used, the less they will be willing to use it.
Parser functions
Parser functions are the WikiMedia toolkit for simple branchings, calculations, text manipulations, etc. As a group, they take one or more parameters & return a wikitext value based on the parameters. There are 2 basic forms for Parser functions (distinguished by whether a pound sign follows the opening brackets):
- Core parser functions, of the form {{functionName: parameter | parameter | ... }}. These functions are part of the core wikimedia software, & should be available in all projects.
- Parser functions from the parserFunctions extension, of the form {{#functionName: parameter | parameter | ... }}. These functions are part of the parserFunctions extension, and may not be available everywhere.
Parser functions: primarily used for the evaluation of parameters or magic words, in order to produce different results in different contexts.
Core parser functions generally deal with text manipulation and WikiMedia specific tasks.
{
From Belthazar's Eggy Forum Post
Thanks to the lovely Belthazar =D
Essentially, the {{{1}}} is a parameter placeholder - the parameters are the things you put between the pipe symbols in a template call. For example, {{Renderegg}} is a template. If I call the template with {{Renderegg|2009|4|Fizz}}, then the 2009, 4 and Fizz are all parameters - by default, they're numbered in order: 1, 2 and 3.
If you look at the renderegg template page, you'll notice it reads:
{{Renderegg/{{{2}}}|filename={{{3}}}|year={{{1}}}}}
When the wiki software parses this, it inserts the first parameter wherever a {{{1}}} appears, the second wherever a {{{2}}} appears, and the third wherever a {{{3}}} appears, etc. So if I insert the parameters from my example above, this becomes:
{{Renderegg/4|filename=Fizz|year=2009}}
(Note: this example might be a little confusing, because the Renderegg template actually calls a series of sub-templates depending on what year it is, and how many eggs you have. And the sub-templates have named parameters rather than numbered parameters. But you get what I mean, I hope. I can continue the explanation, but I don't think you need to understand nested sub-templates to understand parameters.)
So, getting back to my idea, what I've done is replaced the template name itself with a parameter placeholder. That is, instead of calling {{Renderegg|2009|4|Fizz}}, I'm using {{{{{1}}}|2009|4|Fizz}}.
Move up a layer to the page where I call this pseudo-template, I've got {{:Pagename|Renderegg}}. "Renderegg" here is parameter number 1, so the wiki software inserts it wherever a {{{1}}} appears on the called page, and so we get {{Renderegg|2009|4|Fizz}}.
Yes.. I think I am following, though, how does it insert Flategg with just the 1 parameter?
Same deal - you're calling the dummy page with a completely different call, and this time you're inserting "Flategg" as the parameter. So {{:Pagename|Flategg}} would replace every occurrence of {{{1}}} in the page Pagename with "Flategg" just as {{:Pagename|Renderegg}} would replace every occurrence of {{{1}}} in the page Pagename with "Renderegg".
Essentially, your dummy page would be exactly the text of your current Renderegg page (sans the opening blurb) but with {{{1}}} in place of the template name. Then you'd reproduce the list on the Renderegg page by putting {{:Pagename|Renderegg}}, and on the Flategg page by putting {{:Pagename|Flategg}}.
(Mind you, there is a simpler solution - just have everything on one page. Instead of having all the rendered images and all the flat images on separate pages, just have them together. As in Flat1, Render1, Flat2, Render2, etc. It'd require re-doing the templates a little, but it's not too complicated. As to whether it's preferable is another matter altogether. =D )
1. Dummy page
Let's call it George, so it's clear I'm using a unique name. Here you'd have a full list of all the entrants, written out just as the pages currently look, but with no opening blurb and {{{1}}} in place of the template name. This is the page you do all the editing. Like so:
{{TOCright}}
==Pirate1==
{{{{{1}}}|2009|4|Pirate1}}
==Pirate2==
Design 3 does not have enough bananas.
{{{{{1}}}|2009|6|Pirate2}}
==Pirate3==
{{{{{1}}}|2009|1|Pirate3}}
<etc>
Maybe even a <includeonly>'d Category tag at the bottom or something.
2. Renderegg page
Here we call our list of data as though it's a template, using "Renderegg" as parameter number 1. The data will be transcluded, but with all occurrences of "{{{1}}}" replaced by "Renderegg". There's no need to edit this page once it's been created - it just automagically updates when you update the dummy page. Viz:
Opening blurb. Welcome to Renderegg page, etc.
{{:George|Renderegg}}
3. Flategg page
Exactly the same, only we have a unique opening blurb, and the data page is called using "Flategg" as the parameter instead. Note it's exactly the same data, so exactly the same page, only this time we're replacing "{{{1}}}" with "Flategg" when it gets included. Again, there's no need to edit this page after it gets created. Viz:
Opening blurb. Welcome to Flategg page, etc.
{{:George|Flategg}}
Including one page inside another doesn't change the one page, meaning we can still include it in other pages. That's the wonder of templates. =)
They're called templates rather than scripts, and anyone can view them (though you have to be a logged-in user to edit them). You'll find them at Template:Renderegg and Template:Flategg
The sub-templates is where things get a little complicated. As I noted above, the Renderegg template reads:
{{Renderegg/{{{2}}}|filename={{{3}}}|year={{{1}}}}}
When parsed, the wiki software inserts parameters 1, 2 and 3 where the placeholders are - this is a function of the MediaWiki software itself, and not of the template. I'm reasonably sure it's open source if you want to get a hold of that and inspect how it does thing.
Now, you'll notice once the paramteres have been added, that this template is calling another sub-template. So, say I call the Renderegg template with {{Renderegg|2009|1|Fizz) (i.e. it's 2009 and Fizz has made one egg), when I substitute the values, I get:
{{Renderegg/1|filename=Fizz|year=2009}}
So, this is calling a second template called Template:Renderegg/1. There's a separate sub-template for each number of eggs. I've used the /1 template because it's pretty short... as opposed to (say) the /14 template. =)
So, the /1 template reads:
[[{{Renderegg/{{{year}}}}}{{{filename}}}-1.png]]
Passing in the values from before (note here that the sub-template has named parameters, which were also named in the template call above) we get
[[{{Renderegg/2009}}Fizz-1.png]]
Note, this is calling yet another sub-template, Template:Renderegg/2009. This one simply reads:
Image:Egg-rendered-2009-
So, we've reached the end of our string of sub-templates. Now for the magic of templates, the entire text of the template is back-substituted wherever the template call occurs (this process is called "inclusion" or "transclusion" depending on which part of the wiki you're looking at). So if we substitute this into our /1 sub-template above, we get
[[Image:Egg-rendered-2009-Fizz-1.png]]
which you'll recognise as being an image link. Clever, hey? The higher-numbered sub-templates have links for images two, three, four, and so on, which means that rather than having to type out fourteen image links to get fourteen images, we can just type {{Renderegg|2009|14|Dread Pirate Westley}} and it'll generate all the code itself from substitution of the templates and sub-templates.
The Flategg template and sub-templates are exactly the same, except they have "flat" wherever it says "render" or "rendered".
Possibly an easier way to think of it is as a more powerful version of Word's find/replace function. I've asked it to find every ocurrence of the word {{Renderegg}} on a page and replaced it with a image link. The more powerful bit comes in the parameters. Parameters let you do clever things.