Help:List format

From semantic-mediawiki.org
Jump to: navigation, search
List format
What:
Comma-separated list, with additional outputs shown in parentheses
Provided by:
Semantic MediaWiki
Added in version:
0.7
Removed in version:
still supported
Further Requirements:
none
Format name:
list
Authors:
Markus Krötzsch
Categories:
misc

The result format list is used to format query results as comma-separated lists. The format list is the default way of formatting query results for all queries that have no additional printout statements. Similar results formats are ol and ul.

Parameters

Parameter Type Default Description
limit Whole number 20 The maximum number of results to return
offset Whole number 0 The offset of the first result
headers Text show Display the headers/property names
mainlabel Text no The label to give to the main page name
link Text all Show values as links
intro Text empty The text to display before the query results, if there are any
outro Text empty The text to display after the query results, if there are any
default Text empty The text to display if there are no query results
sep Text empty The separator for values
template Text empty The name of a template with which to display the printouts
userparam Text empty A value passed into each template call, if a template is used
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

This format introduces the following additional parameters:

The use of templates for formatting is explained in Help:Result templates.

Examples

{{#ask: [[Category:City]] [[located in::Germany]] }}

Result: Berlin, Frankfurt, Munich, Stuttgart

If more printouts are given, then the format must be requested explicitly:

{{#ask: [[Category:City]] [[located in::Germany]] 
| ?population
| ?area#km² = Size in km²
| format=list
}}

Result: Berlin (Population 3,391,409, Size in km² 891.85 km²344.343 sqmi), Frankfurt (Population 679,664, Size in km² 248.31 km²95.872 sqmi), Munich (Population 1,259,678, Size in km² 310.43 km²119.857 sqmi), Stuttgart (Population 595,452, Size in km² 208.754 km²80.6 sqmi)

The headers can be hidden by giving them empty labels:

{{#ask: [[Category:City]] [[located in::Germany]] 
| ?population =
| ?area#km² = 
| format=list
}}

Result: Berlin (3,391,409, 891.85 km²344.343 sqmi), Frankfurt (679,664, 248.31 km²95.872 sqmi), Munich (1,259,678, 310.43 km²119.857 sqmi), Stuttgart (595,452, 208.754 km²80.6 sqmi)

The same effect is achieved by headers=hide.

Another separator than «,» e.g. «and» can be used if specified by sep:

{{#ask: [[Category:City]] [[located in::Germany]] | sep =  _and_ }}

Result: Berlin and Frankfurt and Munich and Stuttgart

The underscores here are used to create spaces that are not removed by MediaWiki when reading the parameter.

Remarks

Using the format list with templates has the advantage of having the right amount of separators (e.g. «,») between results. For example, one can have a template that formats email lists that can be copied and pasted into an email client, where each entry has the form

Name of person <email@example.com>

It makes sense to set sep=,_ to have a list that uses commas for all separators instead of having the last one being an «and».



This documentation page applies to all SMW versions from 0.7 to the most current version.
      Other languages: de

Help:List format en 0.7


Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox