MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: beta
License No license specified
Translate the ReorderParserPhases extension if it is available at translatewiki.net
Check usage and version matrix.

work withEdit

MediaWiki 1.22-1.23 Optional Semantic MediaWiki 1.18 - 1.19


This extension allow the user to perform complex queries and commands, using MediaWiki built in parser functions, templates, and magic words that require several stages. The ReorderParserPhases extension allows the user to control the operators (parser functions, templates, and magic words) execution order.

case 1: Edit input and operators inside parser functionsEdit

expr = evaluates a mathematical expression and returns the calculated value.

6 = {{#expr: 3 + 3 }}

6 = {{#replace:{{#expr: 3 + 3 }}|+|*}} = {{#replace:6|+|*}}

3*3 = {{#ReorderParserPhases:@1#replace~1~3 + 3~1~+~1~*1@}}

9 = {{#ReorderParserPhases:@1#replace~1~@2#expr~2~3 + 32@~1~+~1~*1@}} = {{#expr: 3 * 3 }}

6 = {{#ReorderParserPhases:@2#replace~2~@1#expr~1~3 + 31@~2~+~2~*2@}} = {{#replace:6|+|*}}

case 2:Create complex semantic parser functionEdit

Semantic Mediawiki parser function

Data is taken from [1] and [2]. You can test the extension by exporting those pages from [3] and importing them into your wiki. Then after installing ReorderParserPhases create a test page and copy the code below to its wiki source code.

It is possible nest parser (and semantic parser) functions without the using ReorderParserPhases. However because all parser functions was the same separator | for their parameters, it could lead to confusion. For complex queries it becomes unclear to which parser function each parameter is referring to. In addition the order of parser function evaluation is different in different versions of SMW, which can cause the code to produce different results and different from that to which way the user. The ReorderParserPhases extension solves all of these problems. Using ReorderParserPhases the user can easily write simple clear (understandable) and unambiguous code.

Simple query with ReorderParserPhasesEdit

Cities in germanyEdit

Cities in germany = multiValuePropFromStrudelAsk1 =

Demo:Berlin, Demo:Cologne, Frankfurt, Munich, Stuttgart =



@1#ask~1~[[Located in::Germany]]~1~?#~format=list~1~link=none~1~headers=hide~1~mainlabel=-~1~searchlabel=-1@


Cities with more then 3 km2Edit

Cities with more then 3 km2 = multiValuePropFromStrudelAsk2 =

Demo:Berlin, Demo:San Diego, France, Munich, Porto, Warsaw =

{{#ReorderParserPhases:@2#arraymap~2~@1#ask~1~[[Area::>3]]~1~?#~format=list~1~link=none~1~headers=hide~1~mainlabel=-~1~searchlabel=-1@~2~,~2~x~2~[[multiValuePropFromStrudelAsk2 ::x]]2@}}


multiValuePropFromStrudelAskAnd =

Demo:Berlin, Munich =

{{#ReorderParserPhases:@2#arraymap~2~@1#ask~1~[[Located in::Germany]][[Area::>3]]~1~format=list~1~link=none~1~headers=hide~1~searchlabel=-1@~2~,~2~x~2~[[multiValuePropFromStrudelAskAnd::x]]2@}}

multiValuePropFromStrudelAskAnd = {{#show:TestAskToSet2ReorderParserPhases|?multiValuePropFromStrudelAskAnd}}


multiValuePropFromStrudelAskOr =

Demo:Berlin, Demo:Cologne, Demo:San Diego, France, Frankfurt, Munich, Porto, Stuttgart, Warsaw =

{{#ReorderParserPhases:@2#arraymap~2~@1#compound_query~1~[[Area::>3]]~1~?#~1~[[Located in::Germany]]~1~format=list~1~link=none~1~headers=hide~1~mainlabel=-~1~searchlabel=-1@~2~,~2~x~2~[[multiValuePropFromStrudelAskOr::x]]2@}}

multiValuePropFromStrudelAskOr= {{#show:TestAskToSet2ReorderParserPhases|?multiValuePropFromStrudelAskOr}}


  • Download and place the file(s) in a directory called ReorderParserPhases in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/ReorderParserPhases/ReorderParserPhases.php";
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

See alsoEdit

List of simple parser function that can be use with this extension:


Semantic Mediawiki parser function

See similar extensionsEdit