Help:List format

From semantic-mediawiki.org
Help:List format列表格式
List format
Outputs results in a comma separates list, with additional outputs shown in parentheses. The output induces class attributes to HTML elements to facilitate easy individual styling.
Further Information
Provided by: Semantic MediaWiki
Added: 0.7
Removed: still supported
Requirements: none
Format name: list
Enabled? Indicates whether the result format is enabled by default upon installation of the respective extension. yes
Authors: Markus Krötzsch
Categories: misc
Table of Contents

The result format list is used to format query results as comma separated lists. The output induces class attributes to HTML elements to facilitate easy individual styling. It is very similar to result format "Plainlist"Outputs results in a comma separates list, with additional outputs shown in parentheses. The output does not provide class attributes to HTML elements (default for queries without printout statements)., result format "Ol"Outputs results as a numbered list, with additional outputs shown in parentheses. and result format "Ul"Outputs results as a bulleted list, with additional outputs shown in parentheses..

If the output should not include class attributes to HTML elements then result format "Plainlist"Outputs results in a comma separates list, with additional outputs shown in parentheses. The output does not provide class attributes to HTML elements (default for queries without printout statements). needs to be used which is also the default result format of Semantic MediaWiki if no result format was specified.

Parameters[edit]

Format specific
Parameter Type Default Description
propsep text , The separator between the properties of a result entry
valuesep text , The separator between the values for a property of a result
template text empty The name of a template with which to display the printouts
named args yes/no no Name the arguments passed to the template
userparam text empty A value passed into each template call, if a template is used
class text empty An additional CSS class to set for the list
introtemplate text empty The name of a template to display before the query results, if there are any
outrotemplate text empty The name of a template to display after the query results, if there are any
sep text , The separator between results
Starting with Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. this result format was overhauled and the following changes were made to the parameters provided:1
  • The "class" parameter was introduced to allow setting an additional CSS class for the output.
  • The "template arguments" parameter was removed. It served no longer any purpose since the "?" prefix for arguments was removed, too.
  • The "propsep" and the "valuesep" parameter were introduced to supplement the "sep" parameter.
See the help page on result format "Plainlist"Outputs results in a comma separates list, with additional outputs shown in parentheses. The output does not provide class attributes to HTML elements (default for queries without printout statements). (formerly result format "Template"Uses a specified template to format and display the results) in case a template is used for formatting the query output.

Examples[edit]

Standard output[edit]

The format must be requested explicitly. Otherwise result format "Plainlist"Outputs results in a comma separates list, with additional outputs shown in parentheses. The output does not provide class attributes to HTML elements (default for queries without printout statements). would be used.

Query
{{#ask:
 [[Category:City]]
 [[Located in::Germany]]
 |format=list
}}
Result

Berlin, Cologne, Frankfurt, Munich, Stuttgart, Würzburg

Extended output[edit]

If more printouts are requested the format must be requested explicitly, too. Otherwise result format "Table"Outputs the results in a table (default for queries with printout statements). would be used.

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²=Area
 |format=list
}}
Result

Berlin (PopulationThe number of inhabitants of some geographical place.: 3,520,061, Area: 891.85 km²344.34 sqmi
)
, Cologne (PopulationThe number of inhabitants of some geographical place.: 1,080,394, Area: 405.02 km²156.38 sqmi
)
, Frankfurt (PopulationThe number of inhabitants of some geographical place.: 679,664, Area: 248.31 km²95.87 sqmi
)
, Munich (PopulationThe number of inhabitants of some geographical place.: 1,353,186, Area: 310.43 km²119.86 sqmi
)
, Stuttgart (PopulationThe number of inhabitants of some geographical place.: 606,588, Area: 207.36 km²80.06 sqmi
)
, Würzburg (PopulationThe number of inhabitants of some geographical place.: 126,635, Area: 87.63 km²33.83 sqmi
)

Hidden headers[edit]

The headers can be hidden by giving them empty labels:

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population=
 |?Area#km²= 
 |format=list
}}
Result

Berlin (3,520,061, 891.85 km²344.34 sqmi
)
, Cologne (1,080,394, 405.02 km²156.38 sqmi
)
, Frankfurt (679,664, 248.31 km²95.87 sqmi
)
, Munich (1,353,186, 310.43 km²119.86 sqmi
)
, Stuttgart (606,588, 207.36 km²80.06 sqmi
)
, Würzburg (126,635, 87.63 km²33.83 sqmi
)

The same effect is achieved by using headers=hide:

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population
 |?Area#km²
 |format=list
 |headers=hide
}}
Result

Berlin (3,520,061, 891.85 km²344.34 sqmi
)
, Cologne (1,080,394, 405.02 km²156.38 sqmi
)
, Frankfurt (679,664, 248.31 km²95.87 sqmi
)
, Munich (1,353,186, 310.43 km²119.86 sqmi
)
, Stuttgart (606,588, 207.36 km²80.06 sqmi
)
, Würzburg (126,635, 87.63 km²33.83 sqmi
)

Changed separator[edit]

Between results[edit]

Another separator between results than "," e.g. "and" can be used if specified by the sep parameter:

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]]
 |sep= and 
}}
Result

Berlin and Cologne and Frankfurt and Munich and Stuttgart and Würzburg

Between properties[edit]

Another separator between results than "," e.g. ";" can be used if specified by the propsep parameter:

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]]
 |?Population
 |?Area#km²=Area
 |format=list
 |propsep=; 
}}
Result

Berlin (PopulationThe number of inhabitants of some geographical place.: 3,520,061; Area: 891.85 km²344.34 sqmi
)
, Cologne (PopulationThe number of inhabitants of some geographical place.: 1,080,394; Area: 405.02 km²156.38 sqmi
)
, Frankfurt (PopulationThe number of inhabitants of some geographical place.: 679,664; Area: 248.31 km²95.87 sqmi
)
, Munich (PopulationThe number of inhabitants of some geographical place.: 1,353,186; Area: 310.43 km²119.86 sqmi
)
, Stuttgart (PopulationThe number of inhabitants of some geographical place.: 606,588; Area: 207.36 km²80.06 sqmi
)
, Würzburg (PopulationThe number of inhabitants of some geographical place.: 126,635; Area: 87.63 km²33.83 sqmi
)

Between property values[edit]

Another separator between results than "," e.g. "and" can be used if specified by the valuesep parameter:

Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]]
 |?Population
 |?Area#km²=Area
 |?Has zoo=Zoo
 |format=list
 |valuesep= and 
}}
Result

Berlin (PopulationThe number of inhabitants of some geographical place.: 3,520,061, Area: 891.85 km²344.34 sqmi
, Zoo: Zoologischer Garten Berlin and Tierpark Berlin)
, Cologne (PopulationThe number of inhabitants of some geographical place.: 1,080,394, Area: 405.02 km²156.38 sqmi
)
, Frankfurt (PopulationThe number of inhabitants of some geographical place.: 679,664, Area: 248.31 km²95.87 sqmi
, Zoo: Zoo Frankfurt)
, Munich (PopulationThe number of inhabitants of some geographical place.: 1,353,186, Area: 310.43 km²119.86 sqmi
, Zoo: Tierpark Hellabrunn)
, Stuttgart (PopulationThe number of inhabitants of some geographical place.: 606,588, Area: 207.36 km²80.06 sqmi
, Zoo: Wilhelma)
, Würzburg (PopulationThe number of inhabitants of some geographical place.: 126,635, Area: 87.63 km²33.83 sqmi
)

The HTML character entities  ,   and   denote a thin space, an en space and an em space respectively, where a thin space is a quarter of the point size, an en space is half the point size and an em space is equal to the point size of the current font. If the output should not be broken at spaces   (non-breaking space) is used.


References

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