Extension:NumerAlpha

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
NumerAlpha

Release status:Extension status beta

ImplementationTemplate:Extension#type Tag, Parser function
DescriptionTemplate:Extension#description Provides methods of inserting incrementing numbers, letters, and roman numerals into pages.
Author(s)Template:Extension#username Thierry G. Veilleux (Kronoxttalk)
Latest versionTemplate:Extension#version 0.7.0 (2015-07-31)
MediaWikiTemplate:Extension#mediawiki 1.23+
Database changesTemplate:Extension#needs-updatephp No
ComposerComposer mediawiki/numer-alpha
LicenseTemplate:Extension#license public domain
Download
TagsTemplate:Extension#tags
  • <in>
  • <ir>
  • <ia>
Hooks usedTemplate:Extension#hook
ParserFirstCallInitManual:Hooks/ParserFirstCallInit

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

Check usage and version matrix.

The NumerAlpha extension methods of inserting incrementing numbers, letters, and roman numerals into pages. You can reset the count at any moment or begin to a specified number.

First this extension was to supplement the Semantic Forms extension allowing to add a numbered table when you use the multiple option but you can also use it in templates by utilizing the {{#tag: }} magic word.

Usage[edit]

There are three forms:

  • a zero(s) padded number. (you can configure in the source code the length of your zero padded number. (0 = no zero padding)
  • Roman numeral (i, ii, iii, iv, etc.)
  • alphabetic (a,b,...,z,aa,ab,...,zz,...)

Tags[edit]

  • <in />
  • <ir />
  • <ia />

all of them in combination with reset=1 or begin=1

See examples.

Parser function[edit]

{{#counter: Counter name | type = Counter type | set = Number }}

Available counter types are "numeral", "alpha" and "roman".

Examples[edit]

Tags[edit]

Example 1

You can reset it using the parameter reset, and restart the count with the parameter begin

<ir />
<ir />
<ir />
<ir />
<ir />
<ir />
<ir />
<ir />
<ir />
<ir />

<ir reset=1 />
<ir />
<ir />
<ir />
<ir />
<ir />

<ia />
<ia />
<ia />

<ir begin=10 />
<ir />
<ir />
<ir />

That will be render like

i ii iii iv v vi vii viii ix


i ii iii iv v


a b c

x xi xii xiii

So it's easy to list the alphabet:

<ia reset=1 /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia /><ia />

abcdefghijklmnopqrstuvwxyz

Example 2
<ia>hello</ia>
<ia>world</ia>
<ia reset=1>goodbye</ia>
<ia>world</ia>
<ia begin=11>jupiter</ia>
<ia>jazz</ia>
<in>hello</in>
<in>world</in>
<in reset=1>goodbye</in>
<in>world</in>
<in begin=11>jupiter</in>
<in>jazz</in>
<ir>hello</ir>
<ir>world</ir>
<ir reset=1>goodbye</ir>
<ir>world</ir>
<ir begin=11>jupiter</ir>
<ir>jazz</ir>

Parser function[edit]

Wikitext (since version 0.6.0)
{{#counter: ExampleCounter |type=numeral |set=9 }}
{{#counter: ExampleCounter }}
{{#counter: ExampleCounter }}
Result

9
10
11

Wikitext (since version 0.7.0)
{{#counter: list-with-levels |level prefix=: }} Start lev 1
{{#counter: }} Stay lev 1
{{#counter: |level=2 }} Jump to lev 2
{{#counter: }} Stay lev 2
{{#counter: |level=1 }} Drop to lev 1
{{#counter: |level=2 }} back to lev 2
{{#counter: |level=3 }} jump to lev 3
Result
1
2
1
2
3
1
1

This allows you to have hierarchical lists. Furthermore, if you add "format=outline" to the first #counter you can get output like:

1
2
2.1
2.2
3
3.1
3.1.1

Installation[edit]

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