Jump to content

Module:Wikidata table/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
{{Lua sidebar}}
mNo edit summary
Line 9: Line 9:
The first cell is the label for the Wikidata entity and it is marked up as a row-header. An "editonwikidata" icon is appended to the first cell.
The first cell is the label for the Wikidata entity and it is marked up as a row-header. An "editonwikidata" icon is appended to the first cell.
The table caption, column headings and scopes, etc. should be supplied externally. See the examples for more detail.
The table caption, column headings and scopes, etc. should be supplied externally. See the examples for more detail.
<syntaxhighlight lang="moin">
<syntaxhighlight lang="wikitext">
{{#invoke:Wikidata table |makerow
{{#invoke:Wikidata table |makerow
|pids= P123, P234+P345, P456, P567/P580-P582, etc. (see below)
|pids= P123, P234+P345, P456, P567/P580-P582, etc. (see below)
Line 33: Line 33:
A convenient function to convert a list of articles into a table.
A convenient function to convert a list of articles into a table.


<syntaxhighlight lang="moin">
<syntaxhighlight lang="wikitext">
{{subst:#invoke:Wikidata table | convert
{{subst:#invoke:Wikidata table | convert
| template = name of template
| template = name of template
Line 41: Line 41:


For example:
For example:
<syntaxhighlight lang="moin">
<syntaxhighlight lang="wikitext">
{{subst:#invoke:Wikidata table | convert | template = Wdtable row/dam | 1 =
{{subst:#invoke:Wikidata table | convert | template = Wdtable row/dam | 1 =
* [[Aoyama Dam]]
* [[Aoyama Dam]]
Line 57: Line 57:
=== Function makerows ===
=== Function makerows ===
This function is simple and is intended to test performance. It is unsuitable for use in articles.
This function is simple and is intended to test performance. It is unsuitable for use in articles.
<syntaxhighlight lang="moin">
<syntaxhighlight lang="wikitext">
{{#invoke:Wikidata table |makerows
{{#invoke:Wikidata table |makerows
|pids= P123, P234, P345, etc. (one property id per column)
|pids= P123, P234, P345, etc. (one property id per column)

Revision as of 22:12, 2 May 2023

This module creates one or more table rows where the data in each cell is taken from Wikidata.

Usage

Function makerow

This function is under development for use in articles. It creates a single table row from one Wikidata entity using a given set of properties. The first cell is the label for the Wikidata entity and it is marked up as a row-header. An "editonwikidata" icon is appended to the first cell. The table caption, column headings and scopes, etc. should be supplied externally. See the examples for more detail.

{{#invoke:Wikidata table |makerow
	|pids= P123, P234+P345, P456, P567/P580-P582, etc. (see below)
	|qid = Q12345 (one entity id for the row)
    |line = HTML color code for horizontal line applied to top of each row (if required)
	|c1 = locally supplied value (overrides value from Wikidata for column 1)
	|c2 = locally supplied value (overrides value from Wikidata for column 2)
	|cN = locally supplied value (overrides value from Wikidata for column N), etc.
	|c1+ = locally supplied value (appends value from Wikidata to column 1)
	|c2+ = locally supplied value (appends value from Wikidata to column 2)
	|cN+ = locally supplied value (appends value from Wikidata to column N), etc.
}}

Notes

  • A table cell can be made up of a combination of multiple properties, qualifiers and references.
  • Whitespace is ignored in the list of pids.
  • The separator for cell values is the comma ,.
  • Within a cell, multiple properties are separated by the plus sign +.
  • Each property can be separated from one or more qualifiers by a forward-slash /.
  • Each qualifier is separated by a hyphen - (although any punctuation other than , + / will work).

Function convert

A convenient function to convert a list of articles into a table.

{{subst:#invoke:Wikidata table | convert
    | template = name of template
    | 1 = list of articles
}}

For example:

{{subst:#invoke:Wikidata table | convert | template = Wdtable row/dam | 1 =
* [[Aoyama Dam]]
* [[Apporo Dam]]
* [[Ariake Dam]]
}}

produces:

{{Wdtable row/dam|qid=Q113189811<!-- Aoyama Dam -->}}
{{Wdtable row/dam|qid=Q113189827<!-- Apporo Dam -->}}
{{Wdtable row/dam|qid=Q113189802<!-- Ariake Dam -->}}

Function makerows

This function is simple and is intended to test performance. It is unsuitable for use in articles.

{{#invoke:Wikidata table |makerows
	|pids= P123, P234, P345, etc. (one property id per column)
	|qids = Q12345, Q23456, Q34567, etc. (one entity id per row)
}}

See also