Count members

Posted by Helmuti_pdorf on 01 May 2013 14:45, last edited by Helmuti_pdorf on 02 May 2013 11:06

Tags: count countmembers countrows css members memberscount rowcount tablecount tables

rating: +2+x

This how-to describes a method for counting the members or admins of a wiki.

Introduction

In the community forum we have sometimes been asked how to count the members of a site or wiki.If you have the standard wiki page "system:members" in use then this how to shows you how to do it.

Solution

It was documented in this question in the community forum where one of the practicable solutions is shown by by user RobElliottRobElliott.

Needed Source Code

Lets assume you want to use your standard members list on the page "system:members". You need to add a CSS module to the page which uses CSS syntax to count the rows of the table. You can add the CSS module either at the top or the bottom of your page.

[[module CSS]]
table { 
   counter-reset: line-number; 
}

td:first-child:before {
  content: counter(line-number) ".";
  counter-increment: line-number;
  padding-right: 0.3em; 
}
[[/module]]

and then you add the module to create the members (or admins) list:
[[module Members]]

Result:

row-numbers.jpg

If you have more than 100 members than the page layout is broken into sets of 100 members, every page starting again with 1.

But this means only that the "page count" at the bottom equals the numbers of hundreds of all members!

With such a technique our own members shows the result: on the first page there are 100 members and on the last (page 3) there are 59 members as at the creation date of this how-to.

That means that at the moment (on 30.4.2013) there are 259 members of this wiki.

Other tables

Notice: in expanded tables I have not yet found a way to stop the counter of the "Header row"

Notice2: in simple tables the header row is NOT counted!

This is a counter of table rows which means you use this CSS numbering for any tables on your site, not just the members list, like these 3 examples:

1.table without border

Row1-cell1 Cell2
Row2-cell1 Cell2

Used Code 1:

[[table]]
[[row]]
[[cell]]
Row1-cell1
[[/cell]]
[[cell]]
Cell2
[[/cell]]
[[/row]]
[[row]]
[[cell]]
Row2-cell1
[[/cell]]
[[cell]]
Cell2
[[/cell]]
[[/row]]
[[/table]]

2.table with border

Row1-cell1 Cell2
Row2-cell1 Cell2

Used Code 2:

[[table style="border:1px solid red;"]]
[[row style="border:1px solid green;"]]
[[cell style="border:1px solid black;"]]
Row1-cell1
[[/cell]]
[[cell style="border:1px solid black;"]]
Cell2
[[/cell]]
[[/row]]
[[row style="border:1px solid green;"]]
[[cell style="border:1px solid black;"]]
Row2-cell1
[[/cell]]
[[cell style="border:1px solid black;"]]
Cell2
[[/cell]]
[[/row]]
[[/table]]

3. simple table

Headcell1 Headcell2
cell1 cell2
cell1 cell2

Used Code 3:

||~ Headcell1 ||~ Headcell2 ||
||cell1||cell2||
||cell1||cell2||

4. simple table with leading cell

Count Headcell1 Headcell2
cell1 cell2
cell1 cell2

Used Code 4:

||~ Count ||~ Headcell1 ||~ Headcell2 ||
|| ||cell1||cell2||
|| ||cell1||cell2||

Author

Thanks to Rob for this Code. It helps a lot in a little problem!

RobElliottRobElliott. Please visit his/her userPage.


Related articles

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.