A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mediawiki.org/wiki/Extension:VariablesExtension below:

Extension:Variables - MediaWiki

The Variables extension allows you to define a variable on a page, use it later in that same page or included templates, change its value, possibly to a value given by an expression in terms of the old value, etc.

It is much like a template, only very lightweight and scoped to only a single page, so you can use many variables on a page without slowing down the wiki with huge numbers of templates. Combine this extension with the ParserFunctions extension for best results.

Assigning a value to a variable[edit]

Assigns the value specifiedvalue to the (already existing or hereby introduced) variable variablename.

Works exactly as #vardefine, but the affected value is printed.

Retrieving the value of a variable[edit]

The value of the variable variablename is produced by

If undefined, this produces an empty string; it does not give an error message.

It is possible to get a default value for the case that the variable is undefined or void:

This is equivalent to:

but it is much shorter and better arranged. Before version 2.0 though, the default value always was expanded. From version 2.0 on the default only gets expanded in case it is actually used.

The value can be used in parser functions, etc.

It supports a second and a third parameter to replace these values.

This is equivalent to:

but it is much shorter and better arranged. Before version 2.5 though, both were always expanded. From version 2.5 on the if and else values only get expanded when their cases are actually entered.

Experimental function introduced in Variables 2.0. This function will output the final, last value a variable has at the end of the page rendering. Naturally, the value will be inserted after the parser went over the entire wiki markup, so this function can't be used in other functions, expecting the right value is being used. Example:

The default value will be used if the variable doesn't exist at the final page rendering stage or if its value is an empty string. The default will be expanded right where the function is used, so the parameter will be expanded, even if it won't be needed.

The ParserFunctions extension must also be installed to use #expr.

Compute x = 2*a + b:

Add one to n:

This extension provides two configuration parameters:

$egVariablesAreVolatile
Allows to disable the parser frame being marked as volatile by the extension, i.e. disable template caching.
Default: true;
$egVariablesDisabledFunctions
Allows to disable specified parser functions provided by this extension.
Default: [];
Example: [ 'var_final', 'vardefineecho' ];

The recommended version of the Variables extension for recent MediaWiki releases is listed below. Older versions of the extensions might work as well, but aren't tested for new MediaWiki releases.

As this extension will not be enabled for wikis run by the Wikimedia Foundation (WMF), here are some alternatives:[1][2][3][4]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4