Extension:Autoincrement

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
Autoincrement

Release status: stable

Implementation Parser extension
Description A variable hook that adds an autoincrementing variable, {{AUTOINCREMENT}}
Author(s) Ævar Arnfjörð Bjarmasontalk
MediaWiki 1.12+
Database changes No
License GPL
Download Template:WikimediaDownload/svn
Hooks used
MagicWordwgVariableIDs

ParserGetVariableValueSwitch

Translate the Autoincrement extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

The Autoincrement extension adds an autoincrementing variable, {{AUTOINCREMENT}}. Each time the hook is used on a page it will return a number increased by one from the last use.

Purpose and usage[edit | edit source]

This template can be used to aid in constructing complex templates, keep track of the number of entries in a table, or any other place you need an incrementing variable, especially in conjunction with ParserFunctions.

Wiki Markup Result
{{AUTOINCREMENT}}, {{AUTOINCREMENT}}, {{AUTOINCREMENT}} 1, 2, 3

{|
| Dog
|-{{AUTOINCREMENT}}
| Cat
|-{{AUTOINCREMENT}}
| Bird
|-{{AUTOINCREMENT}}
|}
There are {{#expr:{{AUTOINCREMENT}}-1}} animals listed in the table above.

Dog
Cat
Bird

There are 3 animals listed in the table above.

Installation[edit | edit source]

To install this, download the latest snapshot and extract it to your extensions directory, the add a line to your LocalSettings.php like

require_once( "$IP/extensions/Autoincrement/Autoincrement.php" );