Help:Plainlist format

From semantic-mediawiki.org
Plainlist format
Flexible new default result format in SMW 3.x replacing template and list formats.
Further Information
Provided by: Semantic MediaWiki
Added: 3.0.0
Removed: still supported
Requirements: none
Format name: plainlist
Enabled? Indicates whether the result format is enabled by default upon installation of the respective extension. yes
Authors: Stephan Gambke
Categories: misc
Table of Contents

The result format plainlist is used to format query results. Since Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. 1 it is the default way of formatting query results for all queries that have no additional printout statements. It replaces the result format "list"Provides a comma-separated list with additional outputs shown in parentheses and result format "template"Uses a specified template to format and display the results. Similar formats are result format "ol"Numbered list, with additional outputs shown in parentheses and result format "ul"Bulleted list, with additional outputs shown in parentheses.

Parameters[edit]

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

The use of templates for formatting is explained on help page for result format "Template"Uses a specified template to format and display the results.

Examples[edit]

The most basic usage of this result format is as follows:

Syntax
{{#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:

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

Berlin (Population: 3,520,061, Size in km²: 891.85 km²344.34 sqmi
), Cologne, Frankfurt (Population: 679,664, Size in km²: 248.31 km²95.87 sqmi
), Munich (Population: 1,353,186, Size in km²: 310.43 km²119.86 sqmi
), Stuttgart (Population: 606,588, Size in km²: 207.36 km²80.06 sqmi
), Würzburg


The headers can be hidden by giving them empty labels:

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

Berlin (3,520,061, 891.85 km²344.34 sqmi
), Cologne, 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

The same effect is achieved by headers=hide.


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

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

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

In contrast to the former result format "list"Provides a comma-separated list with additional outputs shown in parentheses format, the plainlist format is more flexible regarding value separators:

  • sep: separator between results
  • propsep: separator between the properties of a result (printouts)
  • valuesep: separator between the values for a property, if more than one entry exists for a property
Syntax
{{#ask:
 [[Category:City]]
 [[Located in::Germany]] 
 |?Population=
 |?Area#km²= 
 |format=plainlist
 |sep= - 
 |propsep=; 
 |valuesep=, 
}}
Result

Berlin (3,520,061; Point of Interest: Brandenburg Gate, Museumsinsel, Reichstag) - Cologne - Frankfurt (679,664) - Munich (1,353,186; Point of Interest: Dom zu Unserer Lieben Frau, Schloss Nymphenburg) - Stuttgart (606,588) - Würzburg

To be even more flexible (e. g. avoiding the brackets for the results), you can use the template parameter. Usage of templates is described in the (now deprecated) result format "template"Uses a specified template to format and display the results.




This documentation page applies to all SMW versions from 3.0.0 to the most current version.
     


References

  1. ^  Semantic MediaWiki: GitHub issue gh:smw:2488