Help: Variables: Difference between revisions
From A Wiki of Ice and Fire
No edit summary |
mNo edit summary |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
'''Variables''' are a type of '''Magic words''' a strings of text that Wiki software associates with a return value or function. There are three general types of magic words: | |||
< | *'''Variables''': these are uppercase words surrounded by double braces, ''e.g.'' '''<code><nowiki>{{FOO}}</nowiki></code>'''. As such, they look a lot like [[Help:Templates|templates]]. Note that templates use pre set ''parameters'', that are parsed and cashed once you save the page, not each time you load it. | ||
*'''Behavior switches''': these are uppercase words surrounded by double underscores, ''e.g.'' '''__FOO__''' used for adjusting the layout or behavior of the page and can often be used to specify desired omissions and inclusions in the content. | |||
*'''Parser functions''': very similar to variables, but take one or more parameters. See also [http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions Help:Extension:ParserFunctions] which offers great functionality for constructing advance templates. | |||
Here are some useful magic words, for a full list see [http://www.mediawiki.org/wiki/Help:Magic_words Help:Magic words] | |||
{| class="wikitable" | |||
|- | |- | ||
! | ! style="background:#A7C1F2" width=150px| Word | ||
! | ! style="background:#A7C1F2" | Description | ||
|- | |- | ||
| <code><nowiki>__NOTOC__</nowiki></code> | |||
| Hides the table of contents (TOC). | |||
|- | |- | ||
| | | <code><nowiki>__FORCETOC__</nowiki></code> | ||
| Forces the table of content to appear at its normal position (above the first header). | |||
| | |||
|- | |- | ||
| | | <code><nowiki>__TOC__</nowiki></code> | ||
|<nowiki>{ | | Places a table of contents at the word's current position (overriding <code><nowiki>__NOTOC__</nowiki></code>). If this is used multiple times, the table of contents will appear at the first word's position. It is possible to suppress the auto-generated section numbers, if the proper class exists locally at [[MediaWiki:Common.css]], defined as <code>.tocnumber { display: none; }</code>. | ||
|{ | |} | ||
{| class="wikitable" width=100% | |||
|- | |- | ||
| | ! style="background:#A7C1F2" width=150px | Variable | ||
| | ! style="background:#A7C1F2" | Output | ||
| | ! style="background:#A7C1F2" | Description | ||
|- | |- | ||
| | | <code><nowiki>{{FULLPAGENAME}}</nowiki></code> | ||
| {{FULLPAGENAME}} | |||
|{{ | | Namespace and page title. | ||
|- | |- | ||
| <code><nowiki>{{PAGENAME}}</nowiki></code> | |||
| {{PAGENAME}} | |||
| Page title. | |||
|< | |||
|{{ | |||
| | |||
|- | |- | ||
| | | <code><nowiki>{{BASEPAGENAME}}</nowiki></code> | ||
| {{BASEPAGENAME}} | |||
| Page title excluding the current subpage and namespace ("Title/foo" on "Title/foo/bar"). | |||
For more complex splitting, use <code><nowiki>{{</nowiki>#titleparts<nowiki>}}</nowiki></code> from [http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23titleparts ParserFunctions extension]. | |||
|- | |- | ||
| | | <code><nowiki>{{SUBPAGENAME}}</nowiki></code> | ||
| {{SUBPAGENAME}} | |||
| {{ | | The subpage title ("foo" on "Title/foo"). | ||
|- | |- | ||
| | | <code><nowiki>{{SUBJECTPAGENAME}}</nowiki></code> | ||
| {{SUBJECTPAGENAME}} | |||
| {{ | | The namespace and title of the associated subject page. | ||
|- | |- | ||
| | | <code><nowiki>{{TALKPAGENAME}}</nowiki></code> | ||
| {{TALKPAGENAME}} | |||
| The namespace and title of the associated talk page. | |||
| {{ | |||
| | |||
|} | |} | ||
{{Template:WikiHelpNav}} | |||
[[Category:Help|Variables]] | [[Category:Help|Variables]] | ||
Latest revision as of 07:25, 4 February 2012
Variables are a type of Magic words a strings of text that Wiki software associates with a return value or function. There are three general types of magic words:
- Variables: these are uppercase words surrounded by double braces, e.g.
{{FOO}}. As such, they look a lot like templates. Note that templates use pre set parameters, that are parsed and cashed once you save the page, not each time you load it. - Behavior switches: these are uppercase words surrounded by double underscores, e.g. __FOO__ used for adjusting the layout or behavior of the page and can often be used to specify desired omissions and inclusions in the content.
- Parser functions: very similar to variables, but take one or more parameters. See also Help:Extension:ParserFunctions which offers great functionality for constructing advance templates.
Here are some useful magic words, for a full list see Help:Magic words
| Word | Description |
|---|---|
__NOTOC__
|
Hides the table of contents (TOC). |
__FORCETOC__
|
Forces the table of content to appear at its normal position (above the first header). |
__TOC__
|
Places a table of contents at the word's current position (overriding __NOTOC__). If this is used multiple times, the table of contents will appear at the first word's position. It is possible to suppress the auto-generated section numbers, if the proper class exists locally at MediaWiki:Common.css, defined as .tocnumber { display: none; }.
|
| Variable | Output | Description |
|---|---|---|
{{FULLPAGENAME}}
|
Help:Variables | Namespace and page title. |
{{PAGENAME}}
|
Variables | Page title. |
{{BASEPAGENAME}}
|
Variables | Page title excluding the current subpage and namespace ("Title/foo" on "Title/foo/bar").
For more complex splitting, use |
{{SUBPAGENAME}}
|
Variables | The subpage title ("foo" on "Title/foo"). |
{{SUBJECTPAGENAME}}
|
Help:Variables | The namespace and title of the associated subject page. |
{{TALKPAGENAME}}
|
Help talk:Variables | The namespace and title of the associated talk page. |