Demo:Table formats compared

From semantic-mediawiki.org
Table of Contents

Table format[edit]

class=sortable wikitable smwtable[edit]

This is the default result format for queries with printout statements, so |format=table does not need to be specified explicitly. Same applies to |class=sortable wikitable smwtable which is the default class for this result format.

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Size in km²
 |mainlabel=City
 |sort=Population
 |order=descending
 |headers=plain
}}
Result
CityPopulationSize in km²
Berlin3,520,061891.85 km²344.34 sqmi <br />
Munich1,353,186310.43 km²119.86 sqmi <br />
Cologne1,080,394405.02 km²156.38 sqmi <br />
Frankfurt679,664248.31 km²95.87 sqmi <br />
Stuttgart606,588207.35 km²80.06 sqmi <br />
Würzburg126,63587.63 km²33.83 sqmi <br />

class=sortable table[edit]

This example uses the twitter bootstrap classes. It only works, because this wiki uses the "Chameleon" skin. When using Semantic MediaWiki 3.1.0Released on 23 September 2019 and compatible with MW 1.31.0 - 1.33.x. and later and not using Chameleon use class sortable smwtable-clean for a similar results.

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Size in km²
 |mainlabel=City
 |sort=Population
 |order=descending
 |headers=plain
 |class=sortable table
}}
Result
CityPopulationSize in km²
Berlin3,520,061891.85 km²344.34 sqmi <br />
Munich1,353,186310.43 km²119.86 sqmi <br />
Cologne1,080,394405.02 km²156.38 sqmi <br />
Frankfurt679,664248.31 km²95.87 sqmi <br />
Stuttgart606,588207.35 km²80.06 sqmi <br />
Würzburg126,63587.63 km²33.83 sqmi <br />

class=sortable smwtable-clean[edit]

This is the default result format for queries with printout statements, so |format=table does not need to be specified explicitly.

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Size in km²
 |mainlabel=City
 |sort=Population
 |order=descending
 |headers=plain
 |class=sortable smwtable-clean
}}
Result
CityPopulationSize in km²
Berlin3,520,061891.85 km²344.34 sqmi <br />
Munich1,353,186310.43 km²119.86 sqmi <br />
Cologne1,080,394405.02 km²156.38 sqmi <br />
Frankfurt679,664248.31 km²95.87 sqmi <br />
Stuttgart606,588207.35 km²80.06 sqmi <br />
Würzburg126,63587.63 km²33.83 sqmi <br />

class=datatable[edit]

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Size in km²
 |mainlabel=City
 |sort=Population
 |order=descending
 |headers=plain
 |format=table
 |class=datatable
}}
Result

class=datatable compact cell-border[edit]

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Size in km²
 |mainlabel=City
 |sort=Population
 |order=descending
 |headers=plain
 |format=table
 |class=datatable compact cell-border
}}
Result

Broadtable format[edit]

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Size in km²
 |mainlabel=City
 |sort=Population
 |order=descending
 |headers=plain
 |format=broadtable
}}
Result
CityPopulationSize in km²
Berlin3,520,061891.85 km²344.34 sqmi <br />
Munich1,353,186310.43 km²119.86 sqmi <br />
Cologne1,080,394405.02 km²156.38 sqmi <br />
Frankfurt679,664248.31 km²95.87 sqmi <br />
Stuttgart606,588207.35 km²80.06 sqmi <br />
Würzburg126,63587.63 km²33.83 sqmi <br />

Datatables format[edit]

Note that this result format is provided by extension "Semantic Result Formats"Provides additional formats for semantic queries.
Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Size in km²
 |mainlabel=City
 |sort=Population
 |order=descending
 |headers=plain
 |format=datatables
}}
Result