Status: | effective |
Progress: | 100% |
Version: | 3.1.0+ |
Help:Table format
Table format | |
---|---|
Outputs the results in a table (default for queries with printout statements). | |
Further Information | |
Provided by: | Semantic MediaWiki |
Added: | 0.4 |
Removed: | still supported |
Requirements: | none |
Format name: | table |
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 table is used to format query results as tables. It is Semantic MediaWiki's default way of formatting query results for all queries that have one or more additional printout statements. It is almost identical to result format "Broadtable"Outputs the results in a broad table..
Parameters
General
⧼validator-describe-header-parameter⧽ | ⧼validator-describe-header-type⧽ | ⧼validator-describe-header-default⧽ | ⧼validator-describe-header-description⧽ |
---|---|---|---|
source | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | Alternative query source |
limit | ⧼validator-type-integer⧽ | 50 | The maximum number of results to return |
offset | ⧼validator-type-integer⧽ | 0 | The offset of the first result |
link | ⧼validator-type-string⧽ | all | Show values as links |
sort | ⧼validator-type-string-list⧽ | ⧼validator-describe-empty⧽ | Property to sort the query by |
order | ⧼validator-type-string-list⧽ | ⧼validator-describe-empty⧽ | Order of the query sort |
headers | ⧼validator-type-string⧽ | show | Display the headers/property names |
mainlabel | ⧼validator-type-string⧽ | no | The label to give to the main page name |
intro | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | The text to display before the query results, if there are any |
outro | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | The text to display after the query results, if there are any |
searchlabel | ⧼validator-type-string⧽ | ... further results | Text for continuing the search |
default | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | The text to display if there are no query results |
headers=hide
" is specifically useful for hiding the header of tables. In most other cases, it is sufficient to use empty printout labels to hide the titles of printout statements.
Format specific
⧼validator-describe-header-parameter⧽ | ⧼validator-describe-header-type⧽ | ⧼validator-describe-header-default⧽ | ⧼validator-describe-header-description⧽ |
---|---|---|---|
class | ⧼validator-type-string⧽ | sortable wikitable smwtable | An additional CSS class to set for the table |
transpose | ⧼validator-type-boolean⧽ | no | Display table headers vertically and results horizontally |
sep | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | The separator between results |
prefix | ⧼validator-type-string⧽ | none | Control display of namespace in printouts |
- Possible options for parameter "class" are:
datatable
,datatable compact
,datatable cell-border
or the combinationdatatable compact cell-border
.4. These classes makes use of the "DataTables" table plug-in for jQuery5. - Using these classes produces a basic output as offered by result format "Datatables"Provides a complete porting of DataTables JavaScript library into Semantic MediaWiki provided by extension "Semantic Result Formats"No description was provided. which also makes use of the "DataTables" table plug-in for jQuery. The latter is however more powerful in its usage.2
Semantic MediaWiki 3.1.0Released on an unknown date unknown versions of MediaWiki brought the smwtable-clean
class allowing for another alternative to the wikitable smwtable
class combination.6
Sorting
Tables have a special feature for sorting their contents by any of the columns in the table. See Help:Selecting pages for general comments on sorting and a comparison to the wiki's query result sorting. Browsers without JavaScript enabled will not see the buttons for sorting at all.
Examples
The following examples demonstrate the output of simple queries using different classes for generating the respective overall appearance of the table.
sortable wikitable smwtable
This is the default class for queries with printout statements and does not need to be specified explicitly. Same for specifying the format to be used, i.e. format=table
which is the default for queries with printout statements.
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Size |mainlabel=City |sort=Population |order=descending |headers=plain }}
- Result
smwtable-clean
Available since Semantic MediaWiki 3.1.0Released on an unknown date unknown versions of MediaWiki.6 The format to be used (format=table
) does not need to be specified explicitly since it is the default for queries with printout statements. It can be combined with class sortable
provided by MediaWiki core as a utility allowing users to control the sorting of the columns contents (class=smwtable-clean sortable
).
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Size |mainlabel=City |sort=Population |order=descending |headers=plain |class=smwtable-clean }}
- Result
datatable
Available since Semantic MediaWiki 3.0.0Released on an unknown date unknown versions of MediaWiki.1 The format to be used (format=table
) does not need to be specified explicitly since it is the default for queries with printout statements. See below for more related classes.
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Size |mainlabel=City |sort=Population |order=descending |headers=plain |class=datatable }}
- Result
More ...
Appearance
Applying CSS formatting
As of Semantic MediaWiki 1.6.2Released on an unknown date unknown versions of MediaWiki the native MediaWiki sortable tables are used. Thus this format now provides several ways for custom formatting to be applied to tables:
- One or more overall CSS classes can be set for the table, using the "class=" parameter.
- Each column in the table gets a class name that derives from the column name. For instance, if a column is titled "Capital city", the column's class will be "Capital-city".
- Rows in the table each get either the class "row-odd" or "row-even", depending on whether the row is odd or even.
In this way, specific formatting, like colors and font sizes, can be set across a single table, or for a specific column, or can be set for alternating rows. The recommended way to set any custom CSS in the wiki is by modifying the page "MediaWiki:Common.css".
- Example for alternating row colours
The example below will result in the display of alternating rows.
/* even and odd in tables */
.smwtable .row-even {
background-color: #fff;
}
.smwtable .row-odd {
background-color: #cde6ea;
}
- Data value type attributes
Semantic MediaWiki 1.9.0Released on an unknown date unknown versions of MediaWiki introduces type related attribution allowing to apply specific formatting rules based on the datatype uses (data value types like "_dat
", "_num
" etc.) used in a column.7
The class attribute is a concatenated string that includes "smwtype
" + "datavalue typeId
" resulting in "smwtype_dat
" for the data value of datatype "Date". If you want all numeric representations (prerequisite is that the property selected for display is of datatype "Number") in a table to be formatted on the right side, you would need to add:
/* DataValue type formatting */
.smwtable .smwtype_num {
text-align: right;
}
Predefined datatable classes
In contrast to result format "Datatables"Provides a complete porting of DataTables JavaScript library into Semantic MediaWiki, Semantic MediaWiki 3.0.0Released on an unknown date unknown versions of MediaWiki introduced a set of predefined classes supporting a datatable output1 in the table format which allows to search the table and to display more results without bloating the display of the table on the wiki page.23
Possible options for parameter "class" are:
datatable
,datatable compact
,datatable cell-border
or the combination of the previous twodatatable compact cell-border
.4.
These classes makes use of the "DataTables" table plug-in for jQuery5. Using these classes produces a basic output as offered by result format "Datatables"Provides a complete porting of DataTables JavaScript library into Semantic MediaWiki provided by extension "Semantic Result Formats"No description was provided. which also makes use of the "DataTables" table plug-in for jQuery. The latter is however more powerful in its usage. 2
The features of this class are
- nicer visual appearance
- search input box for searching within the table
- easy export of the table's content into CSV, JSON, RSS and RDF
Custom skins
If you are using custom skins other class attributes may be available. E. g. if you use a skin that implements boostrap, you can use class attributes such as
table table-hover table-condensed
table table-hover table-condensed table-responsive sortable