Help:Variable
From Wikipedia, the free encyclopedia.
This is a list of variables that can be used in the wikitext. The way they are rendered depends on the time, on the project, or on the page in which it occurs.
On the left is the variable, on the right how it is rendered at this time, in this project, on this page.
| Contents |
Constant, only depending on the project and parameters
| {{ns:-2}} or {{ns:Media}} | Media |
| {{ns:-1}} or {{ns:Special}} | Special |
| {{ns:1}} or {{ns:Talk}} | Talk |
| {{ns:2}} or {{ns:User}} | User |
| {{ns:3}} or {{ns:User_talk}} | User_talk |
| {{ns:4}} or {{ns:Project}} | WikiPedia |
| {{ns:5}} or {{ns:Project_talk}} | WikiPedia_talk |
| {{ns:6}} or {{ns:Image}} | Image |
| {{ns:7}} or {{ns:Image_talk}} | Image_talk |
| {{ns:8}} or {{ns:MediaWiki}} | MediaWiki |
| {{ns:9}} or {{ns:MediaWiki_talk}} | MediaWiki_talk |
| {{ns:10}} or {{ns:Template}} | Template |
| {{ns:11}} or {{ns:Template_talk}} | Template_talk |
| {{ns:12}} or {{ns:Help}} | Help |
| {{ns:13}} or {{ns:Help_talk}} | Help_talk |
| {{ns:14}} or {{ns:Category}} | Category |
| {{ns:15}} or {{ns:Category_talk}} | Category_talk |
| depending on custom namespaces: {{ns:100}} - {{ns:121}} | - |
| {{SITENAME}} | WikiPedia |
| {{SERVER}} | http://wikipedia.cas.ilstu.edu |
| {{localurl:pagename}} | /index.php/Pagename |
| {{localurl:pagename|query string}} | /index.php?title=Pagename&query string |
| {{int:fromwikipedia}} | <fromwikipedia> |
"INT:" is used to get text from wfMsg, such as messages in the LanguageXx.php file (see example over). It is short for "internal".
Varying with time
| {{CURRENTMONTH}} | 12 |
| {{CURRENTMONTHNAME}} | December |
| {{CURRENTMONTHNAMEGEN}} | December |
| {{CURRENTDAY}} | 1 |
| {{CURRENTDAYNAME}} | Monday |
| {{CURRENTYEAR}} | 2008 |
| {{CURRENTTIME}} | 02:01 |
| {{NUMBEROFARTICLES}} | 0 |
NUMBEROFARTICLES: number of pages in the main namespace which contain a link and are not a redirect, i.e. number of articles, stubs containing a link, and disambiguation pages.
This depends on system variable $wgUseCommaCount If true, article count will only include those with commas (","). If false, will only count those with links ("[["). The default set in DefaultSettings.php is false, this can be changed in LocalSettings.php. See also Help:Article count.
CURRENTMONTHNAMEGEN: is the genitive grammatical form of the month name (used in Finnish).
Depending on page
| {{NAMESPACE}} | Help |
| {{PAGENAME}} | Variable |
| {{PAGENAMEE}} | Variable |
PAGENAMEE displays the page title in the form that is used in URLs, i.e. with underscores for spaces, and escape codes for special characters, and is therefore used for constructing URLs. For example, on a page called "Another test", PAGENAMEE would produce "Another_test" rather than "Another test". See also Variables PAGENAME and PAGENAMEE
When used in a template, these three variables refer to the page in which the template is included, not to the template page.
Depending on revision
{{REVISIONID}}
Would be available in 1.5/2.0 and give out the actual revision of the text (aka the old_id from used in 1.4). Useful for citation in newspaper, scholar works ... It can not be made available in 1.4 or previous.
Reference: bugzilla #1739 (http://bugzilla.wikimedia.org/show_bug.cgi?id=1739)
Examples of combinations
| {{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|action=edit}} | http://wikipedia.cas.ilstu.edu/index.php?title=Help:Variable&action=edit |
| {{SERVER}}{{localurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}} | http://wikipedia.cas.ilstu.edu/index.php?title=Special:Whatlinkshere&target=Help:Variable |
| [[{{NAMESPACE}}:{{PAGENAME}}_1]] | Help:Variable_1 |
| {{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}_1}} | http://wikipedia.cas.ilstu.edu/index.php/Help:Variable_1 |
Note that PAGENAME with single E has to be used within localurl, otherwise it does not work with special characters. For example, for a page named É we get {{localurl:É}}, which correctly gives /index.php/ (with {{SERVER}} in front http://wikipedia.cas.ilstu.edu/index.php/, linking to the page É), while {{PAGENAMEE}} gives %C9, and {{localurl:%C9}} gives {{localurl:%C9}}, i.e. it is rendered unchanged, the function localurl is not applied. With {{SERVER}} in front it gives http://wikipedia.cas.ilstu.edu{{localurl:%C9}}, which is a dead link reported by the browser, the server is not even reached.
See also m:Template:UTC.
In a template, for a link to a page which depends on a template parameter, the external link style is used even for internal links, to avoid that the system links to the edit page even if the page exists. To construct the external link, variables can also be useful.
Variables in links
Variables work also in links:
- [[a{{NAMESPACE}}b|c{{PAGENAME}}d]] gives cVariabled
See also
- Images in templates.
- Help:Template#subst - on applying "subst" to a variable or to a template using a variable
Wikipedia-specific content and links to other help pages
| - edit this Wikipedia- and subject-specific template (http://wikipedia.cas.ilstu.edu/index.php?title=Template:Ph:Variable&action=edit) |
| Help contents - all pages in the Help namespace: Meta (http://meta.wikimedia.org/w/index.php?title=Special%3AAllpages&from=&namespace=12) b: (http://en.wikibooks.org/w/index.php?title=Special%3AAllpages&from=&namespace=12) c: (http://commons.wikimedia.org/w/index.php?title=Special%3AAllpages&from=&namespace=12) n: (http://en.wikinews.org/w/index.php?title=Special%3AAllpages&from=&namespace=12) w: (http://en.wikipedia.org/w/index.php?title=Special%3AAllpages&from=&namespace=12) q: (http://en.wikiquote.org/w/index.php?title=Special%3AAllpages&from=&namespace=12) wikisource (http://en.wikisource.org/w/index.php?title=Special:Allpages&from=&namespace=12) wiktionary (http://en.wiktionary.org/w/index.php?title=Special%3AAllpages&from=&namespace=12)
|

