Template:Table row counter

From Bibliotheca Anonoma
Revision as of 12:37, 5 March 2017 by Antonizoon (talk | contribs) (Protected "Template:Table row counter" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page is a template. It contains no Bibliotheca Anonoma-related information, but should be used as part of other articles. For more information, read Help:Template.

Please do not experiment with this template; you could ruin all pages using this template. If you want to edit this template, copy the text to Template:Sandbox, edit and test it there, and copy it back when it works.

Feel free to voice your opinion regarding this template.

This template counts the number of rows in wikitext tables. It does not work with nested tables, HTML tables, or tables contained in templates. It will also ignore Template:Tag tags and Template:Tag tags.

The template works by getting the wikitext source of a page and counting the number of tables in that source. This means that the template will not return the correct number of rows on preview, as it will still be using the old version of the page to count from. This also means that if there is more than one wikitext table on a page, you need to specify the number or the ID of the table manually.

Usage

Table ID

{{table row counter|id=id}}

Table number

{{table row counter|tableno=number}}

All parameters

{{table row counter|id=id|tableno=number|ignore=number|page=pagename}}

Parameters

  • id - if specified, the template will decide which table to use by its ID. IDs can be assigned to wikitables by adding the text id="id" to the first line of the table (the same line as the {| code). IDs can consist of uppercase letters, lowercase letters and numbers. Whitespace is not permitted.
  • tableno - the number of the table to use, if there is more than one table on the page. Defaults to 1.
  • ignore - the number of rows to ignore. If specified, the template subtracts this number of rows from the count. This is useful if you do not need to count header rows, etc.
  • page - the page to work on. Defaults to the current page.

Example

The table to be used

{| class="wikitable" id="foo"
| Cell 1 || Cell 2
|-
| Cell 3 || Cell 4
|-
| Cell 5 || Cell 6
|}
Cell 1 Cell 2
Cell 3 Cell 4
Cell 5 Cell 6

Code and result

  • {{table row counter|id=foo|page=Template:Table row counter/doc}}