Help:Plainlist format – variable #rownumber

From semantic-mediawiki.org
Variable #rownumber
This help page explains how to add rownumbers to a template.
Keywords

This help page explains the usage of the #rownumber variable when using templates with result format "Plainlist"Outputs results in a comma separated list, with additional outputs shown in parentheses. The output does not provide class attributes to HTML elements (default for queries without printout statements). to display the output of your queries. It was introduced with Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x..1

This variable can only be used in templates defined with parameter template. It starts from 1 and takes an offset into account.

Example[edit]

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]]
 |?Population
 |?Area
 |format=plainlist
 |introtemplate=TableUnnamedArgsRownumberHeader
 |template=TableUnnamedArgsRownumberBody
 |outrotemplate=TableFooter
}}
Result
# City Population Area
1 Berlin 3,520,061 891.85 km²344.34 sqmi <br />
2 Cologne 1,080,394 405.02 km²156.38 sqmi <br />
3 Frankfurt 679,664 248.31 km²95.87 sqmi <br />
4 Munich 1,353,186 310.43 km²119.86 sqmi <br />
5 Stuttgart 606,588 207.35 km²80.06 sqmi <br />
6 Würzburg 126,635 87.63 km²33.83 sqmi <br />

The templates used to create this example: TableUnnamedArgsRownumberHeader, TableUnnamedArgsRownumberBody and TableFooter. The variable was added to template "TableUnnamedArgsRownumberBody" specified with parameter template.

Note
  • The variable is added to the template like, e.g. {{{#rownumber}}}. Prior to Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. like, e.g. {{{#}}}.
  • This variable starts to increment rownumbers at value 1 for all results matching the query condition not just the ones displayed, i.e. limiting the results with parameter limit or offset does not change the rownumbers displayed.

See also[edit]

References

  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:3130