Extension:Counter

MediaWiki extensions manual
OOjs UI icon advanced-invert.svg
Counter
Release status: stable
Implementation Parser function
Description Allows to auto count objects in a page
Author(s) (Rinicktalk)
Maintainer(s) Saga Musix
Latest version 0.2 (2020-08-24)
MediaWiki 1.34+
Database changes No
License Mozilla Public License 2.0
Download

Check usage and version matrix.

The Counter extension allows to auto count objects in a page.

If you change some item to {{#+: item}} you can get the number of item in this article with {{#+: ? item}}

UsageEdit

Description You type You get
Basic usage
simple counter
* Alice: {{#+: agree}}
* Bob: {{#+: agree}}
* Carol: {{#+: disagree}}
* Dave: {{#+: agree}}
* Eve: {{#+: disagree}}
* Isaac: {{#+: agree}}
total:
* '''{{#+: ? agree}} '''
* '''{{#+: ? disagree}}'''
  • Alice: agree
  • Bob: agree
  • Carol: disagree
  • Dave: agree
  • Eve: disagree
  • Isaac: agree

total:

  • 4 agree
  • 2 disagree
simple counter with numbers
# {{#+: 1 person}}
# {{#+: 2 person}}s
# {{#+: 3 person}}s
total: '''{{#+: ? person}}s''' <br />
number of person: '''{{#+: ? | person}}'''
  1. 1 person
  2. 2 persons
  3. 3 persons

total: 6 persons
number of person: 6

a, an, one, two...twenty
{{#+:1 apple}} + {{#+:1 apple}}  + {{#+:1 apple}} + {{#+:2 apple}}s <br />
= '''{{#+:? apple}}s'''

apple + apple + apple + 2 apple
= 5 apples

You can count more than one item in a single tag
We have
{{#+: apple|fruit,red}}, 
{{#+: orange|fruit,yellow}}
and {{#+: 2 banana|fruit,yellow}}s <br />
We have '''{{#+: ? fruit}}s''', '''{{#+: ? | yellow}}''' of them are yellow

We have an apple, an orange and 2 bananas
We have 4 fruits, 3 of them are yellow

Handle special plural
you can add the results
{{#+: 1 man}} and {{#+: 1 man}} and {{#+: 2 men}} <br />
total: '''{{#+: ? men|man,men}}'''

1 man and 1 man and 2 men
total: 4 men

you can also specify that 1 man is 1 men
{{#+: 1 man|men}} plus {{#+: 5 men}}, then {{#+: 2 men|men|-2}} leave <br />
remain: '''{{#+: ? men}}'''

1 man plus 5 men, then 2 men leave
remain: 4 men

InstallationEdit

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