Help:Magic words

Special markup for MediaWiki
(Redirected from WP:VAR)


If you have any questions about how to use the wiki, please go to the discussion section for this page to ask a question.

Submit an Error Report:

Go to Errors and follow the instructions there.

Browsing www.ooda.wiki

Reporting Errors

The Errors page details the steps for reporting errors on the site, but generally adding a discussion to the page where the error occurred, adding a discussion to the errors discussion page, and/or sending an email to the relevant address (listed on the Errors Page)

Searching www.ooda.wiki

Rather than a search bar, www.ooda.wiki uses the Citizen Skin's built in search. This can be activated either by pressing on the magnifying glass button on the side of any web page, or by pressing "/".

Contributing to www.ooda.wiki

Create an Account Or Logging In

The icon on the bottom left under the gear is the user icon. Click it in order to access the Log in or Create Account option.

In the bottom left corner of the screen click on the icon, and then click either create account if you have not made an account yet, or log in if you have. It is recommended that those of you who wish to join this endeavor create a dedicated email account for free at Skiff and use that email address when signing up for OODAwiki.

Join a Contubernium

Edit an Existing Wiki Page:

The button to enter Visual Editing mode is at the top-right hand corner of any wiki page you can edit.

While Logged in, Click on the top right on the edit icon. This will take you into the Visual Editing mode which, once you click on the text on the page allows you to type any text, change text variables, add citations or insert content using the Visual Editing menu bar.

Make sure to hit the Save changes... button located nearby where the edit icon was to enter visual editing mode, and then add a brief description of the changes in order to save any edits.

The icon to the right of the regular edit icon is the "source" edit which allows for more flexibility but is less human readable. However, switching from visual editing to source editing deletes all unsaved text changes, so proceed carefully.

Headings and Table of Contents

Clicking on the Toolbar here will allow you to turn a line into a Heading

While in Visual Editing mode, up in the menu bar, you should see an option titled something like "Paragraph, Heading, Sub-Heading" or similar. Most of the time, your editing will be done in paragraph mode, which is the default and regular text mode. Changing any section of text to one of the sub-headings will lead to it appearing in the table of contents to the right, once sufficient headings and subheadings are created. The table of contents automatically sorts the headings into a functional list, with subheading appearing as indented sections of the hierarchy. Avoid making any extremely large lines of text as a Heading or Sub-Heading, as this reduces the functionality of the table of Contents.

Visual Editing Options menu

The Visual Editing Options Menu is part of the right-justified portion of the toolbar. Note the save changes button to the right of the edit icon as well.

The visual editing options menu allows for editing a page by adding categories, investigating and adding templates, to find and replace specific words, and other useful options. In particular it is recommended to add relevant categories, such as "Patterns of Conflict" to any Patterns of Conflict slide pages to keep the wiki navigable.

Upload an Image:

Insert an image into a Wiki Page:

Create a New Page:

If you go to a url in this wiki that is valid, in the form of www.ooda.wiki/wiki/__new_page_name_here, you can create a new page after adding any amount of content in the visual editor and passing a query captcha. For example, to create the Patterns of Conflict Slide 100 page, you would first go to the url www.ooda.wiki/wiki/Patterns_of_Conflict_Slide_100, and a small amount of content, save changes and then the page will be created.

Create, Prepare or Edit A Day's Featured Article

Similar to the process for creating a new page, you need to create or go to the page of the featured day. For example the page for the day of April 16 2023 was OODA Wiki:Today's featured article/April 16, 2023. An example of an upcoming day without a page would be the page for May 27 of 2023 which will be OODA Wiki:Today's featured article/May 27, 2023. On the relevant day, this page is automatically grabbed on the front page using the Ordinary Date Time Magic Words which pulls all of the text of the page under the section on the main page labeled "Today's Featured Article".

When preparing a featured article for a specific day, make sure that there is a link to the article featured in the Today's featured article page for the day, and Do Not Copy the Entire Featured Article, instead only put in the today's featured article page either a quick summary, or the top few lines of the featured article page.

The Relevant Code for a Sidebar Template

Editing a Sidebar List Template

To edit a sidebar list template, you must first figure out what the actual template is. The fastest way to get to the template edit screen for sidebar lists is by clicking on the small "E" at the bottom right hand corner of the sidebar.

The slower way is to find the source code by clicking edit on any page with the side far you should find something in triple brackets {{{}}} which will be the name of a template being applied to the page. Make sure you are looking at the correct & relevant Template using the name! For instance Template:War is in triple brackets in the John Boyd source code. If you were to click through to the Template:War page, or put into your url bar www.ooda.wiki/index.php?title=Template:War and then hit edit/view source code, you will see how the sidebar is actually written out as a template. If you want to create a new template sidebar, you would do the exact same thing, find a page to be created & then create it if you have the permissions.

The picture for this section shows the section of relevant code.

In order to add a collapsible section in the main list of a sidebar, create something like below. New sections should have list15name..etc, list20name...etc.

| list10name = John Boyd

| list10title = John Boyd

| list10 =

Then the next portion will be the list inside that list, for instance below. On this how to page the * which are used in the actual code portion are rendered as bullets, and the ** is rendered as part of an indented list so be careful of that, as the actual source code will need them to be *. Also note that to make a link you will need to use double brackets [[]]. If you have uncompleted brackets, this will break the template.

Permissions and Group Management

Adding a User to a specific Page Permission

As a logged in Contubernium Admin, Go to the relevant page, and in the options menu for the page, the three dots in the top right, select from the drop down menu "Permissions" which is below the Watch option. In the Editor section of the page, add Regular Contubernium members for the Contubernium assigned to the page. Add Admin Contubernium Members to the Manager Role.

Extensions Used:

Skin:Citizen

Cite

To Do

Magic words (including parser functions, variables and behavior switches) are features of wiki markup that give instructions to OODA WIKI's underlying MediaWiki software. For example, magic words can suppress or position the table of contents, disable indexing by external search engines, and produce output dynamically based on the current page or on user-defined conditional logic. Some of these features are especially useful for templates.

This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation:

General information

In general, there are three types of magic words.

  1. Behavior switches: often appear in double underscores, all uppercase, e.g., __NOTOC__. They will change the behavior of a page, rather than return a value.
  2. Parser functions: all in lowercase. A parser function will be followed by colon and pipe-separated parameters, e.g., {{#ifexpr:Y|Yes|No}}, wrapped in double braces. They will take a value and return a value.
  3. Variables: these are all uppercase, e.g., {{PAGENAME}}. A variable will be wrapped in double braces and will return a value in its place.

The software generally interprets magic words in the following way:

  • Magic words are case sensitive.
  • White space is generously allowed for readability. It will be stripped from the start and end of their keywords and parameters (as is also done in template calls using named parameters).
  • They can be transcluded, even variables "about the current page". This is ensured by the parsing order.
  • Instead of magically transforming into HTML instructions, ‎<nowiki> tags remove this magic so a magic word can itself be displayed (documented), e.g. <nowiki>{{#magic:}}</nowiki>or {{#magic:<nowiki/>}}.

Magic words compared to templates:

  • As with templates, magic words can be transcluded and substituted.
  • The names of magic words are purposely chosen to be unlike the names of templates, and vice versa. Many parser function names will begin with a #(pound or hash), but template names will not start with a #, and probably not end in a :(colon), or be all-uppercase.
  • The first parameter's syntax differs. In {{#magic: p1 | p2 | p3}}, the name is #magicand it is followed by an unspaced :and a required input parameter, p1. With a template, p1is optional and it is preceded by a |(pipe) instead of a :, e.g. {{template|p1}}.

Most magic words can be used in any needed locations on a page; see MOS:ORDER for guidance on where to place magic words that are behavior switches.

Behavior switches

Switch Description
__TOC__ Places the page's table of contents (TOC) at the word's position. This magic word does not work in skins that present the table of contents outside the article content e.g. the default Vector 2022 skin.
__FORCETOC__ Forces the TOC to appear in its default position, even when there are fewer than four headings. Can be used anywhere on a page. This magic word does not work in skins that present the table of contents outside the article content e.g. the default Vector 2022 skin.
__NOTOC__ Suppresses the appearance of the page's TOC. Can be used anywhere on a page.
__NOEDITSECTION__ Hides the "edit" links normally beside all headings on the page. To hide the edit link beside a particular heading, specify the heading using e.g. an HTML tag such as ‎<h2>heading‎</h2> rather than with the usual wiki equals-signs syntax (e.g. == heading ==).
__ARCHIVEDTALK__ Hides the "Reply" button
__NEWSECTIONLINK__ On non-talk pages, adds a "Add topic" link as a means to add a new section to the page.
__NONEWSECTIONLINK__ Removes the "Add topic" link (the add-new-section link) on talk pages.
__NOGALLERY__ Replaces thumbnails on a category page with normal links.
__HIDDENCAT__ Makes a category hidden when included on that category's page.
__INDEX__ Instructs search engines to index the page.
__NOINDEX__ Instructs search engines not to index the page. See OODA WIKI:Controlling search engine indexing.
__STATICREDIRECT__ Prevents the link on a redirection page from being updated automatically when the page to which it redirects is moved (and "Update any redirects that point to the original title" is selected).
__DISAMBIG__ Marks a page as a disambiguation page, adds it to Special:DisambiguationPages and places inward links in Special:DisambiguationPageLinks. (See mw:Extension:Disambiguator.)
{{DISPLAYTITLE:title}} Used to amend the displayed form of the page's title.
{{DEFAULTSORT:sortkey}} Sets the default key (the index) under which the page is categorised.
{{NOEXTERNALLANGLINKS}} (equivalent to {{NOEXTERNALLANGLINKS|*}}) Suppresses the automated inclusion of Wikidata interlanguage links on the lefthand side of the page. Links to particular rather than all languages may be suppressed by using {{NOEXTERNALLANGLINKS|list}}, where list a pipe-delimited list of language codes (e.g. {{NOEXTERNALLANGLINKS|fr|es|ja}} to suppress the French ("fr"), Spanish ("es") and Japanese ("ja") interlanguage links).

Variables

Page name variable Output Description
{{FULLPAGENAME}} Help:Magic words Canonical page name. Title line. Title unless letter-case is altered with {{DISPLAYTITLE}}.
{{PAGENAME}} Magic words Title line excluding namespace.
{{BASEPAGENAME}} Magic words Title of parent page, excluding namespace.
{{ROOTPAGENAME}} Magic words Title of topmost parent (before all subpages), excluding namespace.
{{SUBPAGENAME}} Magic words On a subpage, rightmost portion of current title; higher subpagenames show as backlinks.
{{ARTICLEPAGENAME}} Help:Magic words Title of the subject page associated with the current page. These are useful on talk pages (but see note about Category talk pages).
{{SUBJECTPAGENAME}} Help:Magic words
{{TALKPAGENAME}} Help talk:Magic words Title of the talk page associated with the current page. Useful on subject pages.
{{NAMESPACENUMBER}} 12 Number of the current page's namespace.
{{NAMESPACE}} Help Namespace of the title.
{{ARTICLESPACE}} Help On a talk page, the namespace part of the title of the associated subject page.
{{SUBJECTSPACE}} Help
{{TALKSPACE}} Help talk Namespace of the talk page associated with the current page.
{{FULLPAGENAMEE}},
{{PAGENAMEE}},
 (etc.)
Help:Magic_words,
Magic_words,
(etc.)
Adding an E to the end of the above variables, renders the above encoded for use in MediaWiki URLs (i.e. with underscores replacing spaces).
{{SHORTDESC}} Only works on the English OODA WIKI, where it displays a short description below the article title on mobile platforms.

Note: The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon (:) is used to pass the parameter, rather than a pipe (|) that is used in templates, like {{MAGICWORD:value}}. For example, {{TALKPAGENAME:OODA WIKI:MOS}} returns OODA WIKI talk:MOS on any page.

Note: In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require prefixing a colon to avoid unwanted categorization.

Site variable Output Description
{{SITENAME}} OODA WIKI Site name ($wgSitename).
{{SERVER}} https://www.ooda.wiki Domain URL ($wgServer).
{{SERVERNAME}} www.ooda.wiki Subdomain and domain name.
{{ARTICLEPATH}} /wiki/$1 Relative article path ($wgArticlePath).
{{SCRIPTPATH}} Relative script path ($wgScriptPath).
{{STYLEPATH}} /skins Relative style path ($wgStylePath).
{{CURRENTVERSION}} 1.39.2 Returns current MediaWiki version.

Other variables by type

Current date and time
Universal time Local-website time
Variable Output Variable Output
{{CURRENTYEAR}} 2024 {{LOCALYEAR}} 2024
{{CURRENTMONTH}} 11 {{LOCALMONTH}} 11
{{CURRENTMONTHNAME}} November {{LOCALMONTHNAME}} November
{{CURRENTMONTHABBREV}} Nov {{LOCALMONTHABBREV}} Nov
{{CURRENTDAY}}[lower-alpha 1] 21 {{LOCALDAY}}[lower-alpha 1] 21
{{CURRENTDAY2}}[lower-alpha 1] 21 {{LOCALDAY2}}[lower-alpha 1] 21
{{CURRENTDOW}} 4 {{LOCALDOW}} 4
{{CURRENTDAYNAME}} Thursday {{LOCALDAYNAME}} Thursday
{{CURRENTTIME}} 15:51 {{LOCALTIME}} 07:51
{{CURRENTHOUR}} 15 {{LOCALHOUR}} 07
{{CURRENTWEEK}} 47 {{LOCALWEEK}} 47
{{CURRENTTIMESTAMP}}[lower-alpha 2] 20241121155147 {{LOCALTIMESTAMP}}[lower-alpha 2] 20241121075147
Page revision data
Variable Output
{{REVISIONDAY}}[lower-alpha 1] 5
{{REVISIONDAY2}}[lower-alpha 1] 05
{{REVISIONMONTH}} 11
{{REVISIONYEAR}} 2023
{{REVISIONTIMESTAMP}}[lower-alpha 2] 20231105235340
{{REVISIONUSER}}[lower-alpha 3] Isidore
  1. 1.0 1.1 1.2 1.3 1.4 1.5 {{CURRENTDAY}}, {{LOCALDAY}} and {{REVISIONDAY}} return the day (e.g. "6"), whilst {{CURRENTDAY2}}, {{LOCALDAY2}} and {{REVISIONDAY2}} return the day with zero-padding (e.g. "06"). For all two-digit days (i.e. 10 to 31), these are the same.
  2. 2.0 2.1 2.2 These timestamp outputs can be formatted with {{Format revisiontimestamp}} (aka {{FRTS}}). For example, {{FRTS|{{REVISIONTIMESTAMP}}}} turns "20231105235340" into "Template:FRTS".
  3. This shows the last user to edit the page. There is no way to show the user viewing the page with magic words due to technical restrictions.
Wiki statistics
{{NUMBEROFPAGES}} 18,520
{{NUMBEROFARTICLES}} 2,347
{{NUMBEROFFILES}} 4,424
{{NUMBEROFEDITS}} 21,788
{{NUMBEROFUSERS}} 60
{{NUMBEROFADMINS}} 3
{{NUMBEROFACTIVEUSERS}} 0

Parser functions

Metadata

Function Description
{{PAGEID}} Unique page identifier number (for example, this page's ID is 3864).
{{PAGESIZE:fullpagename}} Size of named page in bytes (for example, this page is 33,100 bytes).
{{PROTECTIONLEVEL:action|fullpagename}} Protection level assigned to action ("edit", "move", etc.) on named page (this page's protection level for "edit" is ).
{{PROTECTIONEXPIRY:action|fullpagename}} Protection expiry assigned to action ("edit", "move", etc.) on named page (this page's protection expiry is infinity).
{{PENDINGCHANGELEVEL:fullpagename}} Protection level for pending changes on the named page (this page, which doesn't have one, is Template:PENDINGCHANGELEVEL).
{{PAGESINCATEGORY:categoryname}} Number of pages in the category named categoryname. Each subcategory is counted as one item.
{{NUMBERINGROUP:groupname}} Number of users in the user group named groupname.

Page IDs can be associated with articles via wikilinks (i.e. Special:Redirect/page/3235121goes to this page). To output numbers without comma separators (for example, as "123456789" rather than "123,456,789"), append the parameter |R.

Formatting

Function Description
{{lc:string}} Converts all characters in string to lower case.
{{lcfirst:string}} Converts first character of string to lower case.
{{uc:string}} Converts all characters in string to upper case.
{{ucfirst:string}} Converts first character of string to upper case.
{{formatnum:unformatted_number}}
{{formatnum:formatted_num |R}}
Adds comma separators to an unformatted_number (e.g. 123456789 becomes 123,456,789). To remove such formatting, use {{formatnum:formatted_number|R}} (i.e. {{formatnum:7,654,321|R}}, for example, produces 7654321).
{{#dateformat:date|format}}
{{#formatdate:date|format}}
Formats a date according to user preferences; a default can be given as an optional case-sensitive second parameter for users without date preference; can convert a date from an existing format to any of dmy, mdy, ymd, or ISO 8601 formats, with the user's preference overriding the specified format.
{{padleft:xyz|stringlength}}
{{padright:xyz|stringlength}}

{{padleft:xyz|length|padstr}}
{{padright:xyz|length|padstr}}
Pad with zeroes '0' to the right or left, to fill the given length; an alternative padding string can be given as a third parameter; the repeated padding string (padstr) will be truncated if its length does not evenly divide the required number of characters.
{{plural:N|singular|plural}} Outputs singular if N is equal to 1, otherwise outputs plural. See the documentation at mediawiki.org for more details.
{{#time:format|object}}
{{#timel:format|object}}

{{#time:d F Y|date|langcode}}
Used to format dates and times, for ISO format, dots or English month names. #timel is based on local time as defined for each wiki; for English OODA WIKI, this is identical to #time.
The optional 3rd parameter is the output language code (French, German, Swedish: fr, de, sv, etc.). Example Finnish: {{#time:d F Y|June 30, 2016|fi}} shows: 30 kesäkuu 2016 (June). ISO to German: {{#time:d. M Y|1987-10-31|de}} shows: 31. Okt. 1987.
For format codes, see: mw:Help:Extension:ParserFunctions##time. Use the format {{#time: H:i, j F Y (e)|...}} to match the format used by timestamps in signatures.
{{gender:user|m_out|f_out|u_out}} Outputs m_out, f_out or u_out according to whether the gender specified in user's preferences is, respectively, male, female or unspecified. Other parameter permutations are available, see mw:Help:Magic words#gender and translatewiki:Gender.
{{#tag:tag|content with magic}} Only way to evaluate magic words inside a tag, in order to generate <tag>magic</tag>. Also handles tag attributes.

Paths

Function Description
{{localurl:fullpagename |query}} Relative path to page name. The query parameter is optional.
{{fullurl:fullpagename |query}} Absolute path, without protocol prefix (i.e. without "http:" etc.), to page name. The query parameter is optional.
{{canonicalurl:fullpagename |query}} Absolute path, including protocol prefix, to page name. The query parameter is optional.
{{filepath:filename}} Absolute path to the media file filename.
{{urlencode:string}} Encodes string for use in URL query strings; {{urlencode:test string}}, for example, produces: test+string. To encode string for use in URL paths or MediaWiki page names, append, respectively, |PATH or |WIKI (to produce "test%20string" or "test_string").
{{anchorencode:string}} Input encoded for use in MediaWiki URL section anchors.
{{ns:n}} Returns the name of the namespace whose index is the number n. For MediaWiki URLs, use {{nse:}}.
{{#rel2abs:path}} Converts a relative file path to an absolute path.
{{#titleparts:fullpagename|number|first segment}} Splits the fullpagename (title) into that number of segments.

Conditional

Function Description
{{#expr:expression}} Evaluates expression (see m:Help:Calculation).
{{#if:string |result1 |result2}} Outputs result2 if string is empty, otherwise outputs result1.
{{#ifeq:string1|string2 |result1 |result2}} Outputs result1 if string1 and string2 are equal (alphabetically or numerically), otherwise outputs result2.
{{#iferror:test_string |result1 |result2}} Outputs result1 if test_string generates a parsing error, otherwise outputs result2.
{{#ifexpr:expression |result1 |result2}} Outputs result1 if expression is true, otherwise outputs result2.
{{#ifexist:pagetitle |result1 |result2}} Outputs result1 if the page [[pagetitle]] exists, otherwise outputs result2. Note that underscores are needed for spaces in namespaces.
{{#switch:string |c1=r1 |c2=r2 ... |default}} Outputs r1 if string is c1, r2 if string is c2, etc., otherwise outputs default (if provided).

If, in these conditional functions, empty unnamed parameters are to be parsed as empty rather than as text (i.e. as empty rather than as the text "{{{1}}}", "{{{2}}}", etc.), they will require trailing pipes (i.e. {{{1|}}}, {{{2|}}}, etc., rather than {{{1}}}, {{{2}}}, etc.).

Other

Function Description
{{#babel:code1|code2|...}} Render userboxes telling your language skills. Improves upon {{Babel}} (an alternative).
{{#categorytree:category|...}} List pages in a category, recursively.
{{#coordinates:arg1|arg2|...}} Save the GeoData coordinates of the subject to the page's database. Used in {{coord}}.
{{#invoke:module|function|arg1|...}} Use Scribunto to transclude a lua template, e.g. function replace in module String.
{{#language:code1|code2}} Print the name represented by the language code, e.g. enEnglish. Print in language 2 if given, e.g. {{#language:en|zh}} prints 英语
{{#lst:}}, {{#lsth:}}, {{#lstx:}} Three ways to transclude a section of a page.
{{#mentor:Username}} Display the currently assigned mentor for target Username, if set.
{{#property:arg1|arg2|...}} Include a property (Wikidata) from a named entity, instead of the default on the page.
{{#related:...}} Links to similar topics, to engage readers. (Beta feature.)
{{#section:}}, {{#section-h:}}, {{#section-x:}} Aliases for {{#lst:}}, {{#lsth}}, {{#lstx}} (above).
{{#statements:arg1|...}} Display the value of any statement (Wikidata) included in an item.
{{#target:fullpagename}} Send a message to a list of talk pages on the fullpagename, using the MassMessage function.
{{int:pagename}} Transclude an interface message, i.e. a pagename in MediaWiki namespace
{{!}} Used to include a pipe character as part of a template argument or table cell contents. Before this was added as a magic word, many wikis implemented this by creating Template:! with | as the content.
{{=}} Used to include an equal sign as part of a template argument or table cell contents. Before this was added as a magic word, many wikis implemented this by creating Template:= with = as the content.

See also

he:עזרה:משתנים