Extension:Substitutor

From mediawiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced-invert.svg
Substitutor
Release status: unmaintained
Implementation Tag , Parser function
Description Allows to do one-time string substitutions
Author(s) Simon Heimler (Fannontalk)
Latest version 1.2.0 (February 2016)
MediaWiki 1.19+
PHP 5.2+
Database changes No
License MIT License
Download
README

Check usage and version matrix.

The Substitutor extension allows to to do one-time string substitutions.

Description[edit]

Common parser functions and magic words in MediaWiki are parsed/displayed dynamically in MediaWiki. Sometimes this is not what you want. For example, you want a timestamp that is only evaluated the first time the page is saved and after that stay on that exact time. Or you want to generate a random ID that does not change with each page view.

This provides useful if you want to create unique names and URL's for "red links", or simply timestamp sites / changes.

Installation[edit]

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


Instead of downloading the zip archive you may also check this extension out via Git:

git clone https://github.com/Fannon/Substitutor.git

Usage[edit]

Use the <substitute> tag, to define

The content of the tag will be parsed and replaced after you saved the article. The substitution will only happen exactly once - that's the whole point of this extension.

This extension is especially useful in combination with Extension:IDProvider.

Examples[edit]

<substitute>{{#idprovider-random:}}</substitute>

<substitute>{{#idprovider-increment:Test_}}</substitute>

<substitute>{{CURRENTTIMESTAMP}}</substitute>

<substitute>{{Welcome}}</substitute>

Substitute vs. subst:[edit]

<substitute>{{#idprovider-random:}}</substitute>
{{subst:{{#idprovider-random:}}}}

results in:

2a108083-e135-4cd1-a440-2aa78894f3e5<br>
{{subst:{{#idprovider-random:}}}}

which is rendered as:

2a108083-e135-4cd1-a440-2aa78894f3e5
{{subst:65f26d29-5415-4e46-9a4f-af2006e7a357}}