#ask: syntax – "width" printout formatter

From semantic-mediawiki.org
< #ask: syntax elements(Redirected from #ask: syntax – "width" printout formatter)
#ask: syntax elements#ask: syntax – "width" printout formatter
#ask: syntax details:
Syntax
+width=
Description Defines a width for a printout column1
Datatype support All datatypes
Component printout
Software Semantic MediaWiki
Since version Semantic MediaWiki 3.0.0 Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x.
Keyword table format

The +width= query printout formatter for columns was introduced in Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x..

Rationale[edit]

Allows to define a width for the table column for result format "table"Outputs the results in a table (default for queries with printout statements). or result format "broadtable"Outputs the results in a broad table. using the +width= query parameter. Thus it enables different tables on the same page to be formatted with the same width without relying on result format "template"Uses a specified template to format and display the results or individually defined CSS classes added via the class parameter.

The value set with the +width= query parameter denotes the width the respective result column should take. The value consists of an integer together with either "%", "px" or "em" as a unit like e.g. |+width=50%, |+width=25px or |+width=10em.

This query parameter does not allow to manipulate the main result column handled with the mainlabel query parameter.2 See the example below on how to still achieve the desired printout easily.

Examples[edit]

Syntax
{{#ask:
 [[Category: Foo]]
 |?Has text |+width=50%
 |?Has number |+width=10em
 |?Has date |+width=20px
 |format=table
}}

or

{{#ask:
 [[Category: Foo]]
 |?Has text |+width=50%
 |?Has number |+width=10em
 |?Has date |+width=20px
 |format=broadtable
}}
Syntax for manipulating the main result column
{{#ask:
 [[Category: Foo]]
 |? |+width=20%
 |?Has text |+width=50%
 |?Has number |+width=10em
 |?Has date |+width=20px
 |format=table
 |mainlabel=-
}}

What you do here is that you hide the main result column with |mainlabel=- and add it at the same time with |? which in turn allows you to apply the query parameter described on this page.

Link

<sandbox.semantic-mediawiki.org>: More examples for this query parameter

See also[edit]


References

  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:2677
  2. ^  Semantic MediaWiki: GitHub issue comment gh:smw:2677:333343292