Help:List format

From semantic-mediawiki.org
Jump to: navigation, search
List format
Comma-separated list, with additional outputs shown in parentheses
Available languages
deenzh-hans
Further Information
Provided by: Semantic MediaWiki
Added: 0.7
Removed: still supported
Requirements: none
Format name: list
Enabled by default: 
Indicates whether the result format is enabled by default upon installation of the respective extension.
yes
Authors: Markus Krötzsch
Categories: misc
Group:
Table of Contents

↓ INFO ↓

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
sep text , The separator for values
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
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
import-annotation yes/no no <smw-paramdesc-import-annotation>

The use of templates for formatting is explained on help page Template format.

Examples

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

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

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,520,061, Size in km² 891.85 km²
344.343 sqmi
), Cologne, Frankfurt (Population 679,664, Size in km² 248.31 km²
95.872 sqmi
), Munich (Population 1,353,186, Size in km² 310.43 km²
119.857 sqmi
), Stuttgart (Population 606,588, Size in km² 207.36 km²
80.062 sqmi
), Würzburg

The headers can be hidden by giving them empty labels:

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

Result:

Berlin (3,520,061, 891.85 km²
344.343 sqmi
), Cologne, Frankfurt (679,664, 248.31 km²
95.872 sqmi
), Munich (1,353,186, 310.43 km²
119.857 sqmi
), Stuttgart (606,588, 207.36 km²
80.062 sqmi
), Würzburg

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 =  &nbsp;and&nbsp; }}

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

The HTML code &nbsp; (non-breaking space) is used here 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=,&nbsp; 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 1.7.0 to the most current version.
Other versions: 0.7 – 1.6.2       Other languages: dezh-hans

Help:List format en 1.7.0