Help:Variable

From No Subject - Encyclopedia of Psychoanalysis
Jump to: navigation, search

Editing overview

Starting a new page

  1. Page name

Images and other uploaded files

  1. Image description page

Special characters

Formatting

  1. Formula
  2. Table
  3. EasyTimeline syntax

Referencing

  1. Link
  2. Piped link
  3. Interwiki linking
  4. Variable
  5. URL

Organizing

  1. Sections
  2. Templates
  3. Category
  4. Redirect
  5. Renaming (moving) a page
  6. Namespace

Saving effort (not having to write something, or copy and paste)

  1. Automatic conversion of wikitext
  2. Editing toolbar

HTML in wikitext

Fixing mistakes and vandalism

  1. Reverting a page to an earlier version

Communicating

  1. Edit summary
  2. Talk page
  3. Edit conflict
  4. Minor edit

Testing 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.

The names of the variables form part of the set of so-called "magic words" the system uses. [1]

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}} Project
{{ns:5}} or {{ns:Project_talk}} Project talk
{{ns:6}} or {{ns:Image}} File
{{ns:7}} or {{ns:Image_talk}} File 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:101}}, etc.
Portal, Portal talk, etc.
{{SITENAME}} No Subject - Encyclopedia of Psychoanalysis
{{SERVER}} https://nosubject.com
{{SERVERNAME}} nosubject.com
{{localurl:pagename}} /Pagename
{{localurle:pagename}} /Pagename
{{localurl:pagename|query string}} /index.php?title=Pagename&query string
{{fullurl:pagename}} https://nosubject.com/Pagename
{{fullurl:pagename|query_string}} https://nosubject.com/index.php?title=Pagename&query_string
{{int:fromwikipedia}} ⧼fromwikipedia⧽


The variable localurl replaces spaces by underscores and special characters by escape codes, e.g. {{localurl:a é}} gives /A_%C3%A9. The purposes are:

  • for a given page name, creating a link in external link style to a page in the same project or a project which uses the same string in the URL between the server name and the page name (on Wikimedia "/wiki/" and "w/index.php?title=") (but see also m:Template talk:Pi).
  • allow the same wikitext to be used in a project that uses a different string, if the target is in that other project or a project which uses the same string

The pagename in localurl should not be written with escape codes: e.g. use {{SERVER}}{{localurl:À}} giving https://nosubject.com/%C3%80, not {{SERVER}}{{localurl:%C3%80}} giving https://nosubject.com/%C3%80 .

Note that localurl does not convert page names and user names after "target=". This syntax can be avoided by putting the target in the first part of localurl, after the "/":

Localurle (and its counterpart, fullurle) perform additional character escaping on the resulting link, and are intended for internal use only, and work in wikitext only for backwards-compatibility reasons. The unescaped versions should always be used in wikitext.

The {{fullurl}} variable introduced in recent versions allows the entire link to be specified in one go, without also using {{server}}. This also means it can be used in the same way for local and interwiki links (it being clearly inappropriate to add {{server}} before the latter)

Using Template:Tcw, instead of using SERVER and localurl, one can also use e.g. {{url}}abc&action=edit giving Template:Urlabc&action=edit.

"INT:" is used to get text from the Mediawiki: namespace. If the user's interface language, as specified in Special:Preferences, is the wiki's default language, it will display the contents of Mediawiki:pagename. If the user has selected another language, it will display the contents of Mediawiki:pagename/languagecode (e.g. Mediawiki:fromwikipedia/fr for French) if such a page exists, and of Mediawiki:pagename if it does not. It is short for "internal".

Varying with time

{{CURRENTMNTH}} Template:CURRENTMNTH --One digit when month is below 10; en.wikipedia only, see en:Template:CURRENTMNTH (backlinks, edit).
{{CURRENTMONTH}} 03 --Two-digit month number.
{{CURRENTMONTHNAME}} March
{{CURRENTMONTHABBREV}} Mar
{{CURRENTMONTHNAMEGEN}} March
{{CURRENTWEEK}} 12
{{CURRENTDAY}} 18 --One digit when day is below 10.
{{CURRENTDAY2}} 18 --Two-digit day of month; requires additional templates, see Template:Tim.
{{CURRENTDAYNAME}} Monday
{{CURRENTDOW}} 1 --One-digit day of the week; 0=Sunday, 1=Monday ... 6=Saturday
{{CURRENTYEAR}} 2024
{{CURRENTTIME}} 04:16
{{NUMBEROFARTICLES}} 4,366
{{NUMBEROFFILES}} 3,563

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.

CURRENTWEEK is not supported in earlier versions of MediaWiki. It ranges from 1 to 54.

CURRENTMONTHNAMEGEN: is the genitive grammatical form of the month name (used in Finnish).

See also Template:Tim.

Subst

When a template containing {{<includeonly>subst:</includeonly>CURRENTDAY}} is subst'ed, the day of doing that is put in the wikitext, and similarly for other variables.

Depending on page

{{NAMESPACE}} Help
{{NAMESPACEE}} Help
{{PAGENAME}} Variable
{{PAGENAMEE}} Variable
{{FULLPAGENAME}} Help:Variable
{{FULLPAGENAMEE}} Help:Variable

{{NAMESPACE}} and {{NAMESPACEE}} both return nothing (not even a space) in the article namespace. Thus, {{NAMESPACE}}{{PAGENAME}} is equivalent to {{FULLPAGENAME}}, and likewise for {{NAMESPACEE}}{{PAGENAMEE}}.

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 "Grand café", PAGENAMEE would produce "Grand_caf%C3%A9". Do not use PAGENAMEE as the pagename in first part of the variable localurl, see above. 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.

Subst

When a template containing {{<includeonly>subst:</includeonly>PAGENAME}} is subst'ed in a page, the name of the latter page is put in the wikitext, and similarly for other variables.

Depending on revision

{{REVISIONID}} gives 1481

REVISIONID displays a unique number identifying a version of a page in the set of all versions of all pages. In the URL the number can be referred to as "old_id=..", even when the version is still the current one. This can be useful on talk pages, and for citation in newspaper, scholar works, etc. When applying such a URL, at the top of the page the date and local time (if not logged in: UTC) are displayed, with a link to the previous version, and a link to the next version (unless at the time of loading the page there is no newer version: in that case the text "Newer revision" appears anyway, but it is not a link; if the version is the first, a link labeled "previous revision" appears anyway, but it leads to the same page)

The page history page also uses such a URL.

In a preview the value of REVISIONID is 0.

Examples of combinations

{{fullurl:{{FULLPAGENAME}}|action=edit}} https://nosubject.com/index.php?title=Help:Variable&action=edit
{{SERVER}}{{localurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}https://nosubject.com/index.php?title=Special:Whatlinkshere&target=Help:Variable
{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|action=edit}} https://nosubject.com/index.php?title=Help:Variable&action=edit
{{SERVER}}{{localurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}https://nosubject.com/index.php?title=Special:Whatlinkshere&target=Help:Variable
[[{{NAMESPACE}}:{{PAGENAME}}_1]] Help:Variable_1
{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}_1}} https://nosubject.com/Help:Variable_1
{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|oldid={{REVISIONID}}}} https://nosubject.com/index.php?title=Help:Variable&oldid=1481

[Note that {{SERVER}}{{localurl... can be replaced by {{fullurl... in recent (>1.5.5) versions of the software.]

As a link the last example is not useful in the page itself, but it gives useful info about the original in a paper or HTML copy of the page, and provides a link to that in the HTML copy. Also the rendered URL can be copied to the wikitext of this or another page, to refer to the version at the time of copying, e.g. http://meta.wikimedia.org/w/index.php?title=Help:Variable&oldid=178844 (For the latter purpose one can also use the link targets on the page history page).

As mentioned above, 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 /%C3%89 (with {{SERVER}} in front https://nosubject.com/%C3%89, 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 https://nosubject.com{{localurl:%C9}}, which is a dead link reported by the browser, the server is not even reached.

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


Edit

No Subject - Encyclopedia of Psychoanalysis-specific information

Template:Ph:Variable

Edit
Help contents
Reading
Go|Search|Stop words|URL|Namespace|Page name|Section
Backlinks|Link|Piped link|Interwiki link|Redirect|Category|Image page
Logging in and preferences
Logging in|Preferences|User style|Special page
Keeping track of changes
Recent changes (enhanced)|Related changes|Watching pages|Page history
Diff|Edit summary|Minor edit|User contributions
Editing
Filling the page|Starting a new page|List|Table|Special characters
Template|Magic words|Renaming (moving) a page|Editing shortcuts
Talk page|Testing
Advanced
Advanced templates|Array|Parameter default|Variable|Substitution
Displaying a formula|EasyTimeline|Inputbox|Uploading files|Calculation
Lists of resources
Categories|Stub types|Infoboxes|Templates|Shortcuts

This page is a copy of the master help page at Meta (for general help information), with Wikipedia-specific templates inserted. To update the general help, edit the master help page for all projects at m:Help:Variable. For Wikipedia-specific help, there are two templates - the main template, Template:Ph:Variable, is the extra text at the bottom of this page, before the links to other help pages. Template:Phh:Variable appears at the top of this help page and is useful for Wikipedia-specific lead text. You are welcome to copy the exact wikitext from the master page at Meta and paste it into this page at any time.


Copies of this page on other projects, for other languages see Meta
Meta (master page)|Wikinews|Wikiquote|Wiktionary