Template:WikidataOI/doc
This is a documentation subpage for Template:WikidataOI. It may contain usage information, categories and other content that is not part of the original template page. |
Related pages |
---|
This template uses Lua: |
This template uses Lua: |
This template is intended to fetch data from Wikidata with or without a link to the connected Wikipedia article.
The template is under development and is not yet complete. Of the available datatypes, it currently supports strings, quantities, monolingual text, time and globe coordinates.
Usage
[edit source]{{wikidataoi|function|flag1|flag2|flag3|arg1|arg2|arg3}}
Functions
[edit source]property
Returns the requested property or list of properties from the given item.qualifier
Returns the requested qualifier or list of qualifiers from the given property of the given item.propertyWithQualifier
Returns the requested property and its requested qualifier or a list thereof from the given item, with the qualifier formatted between parentheses behind the property and with units of measurement if applicable.label
Returns the label of the given item or property. In case of an item that has no label, the title of the linked page will be returned instead if it exists.title
Returns the title of the page linked to the given item if it exists. Any label of the item will never be returned instead.
Parameters
[edit source]Flags
[edit source]linked
Creates a link to the Wikipedia article that is connected to the property or qualifier if it exists. Also links units of measurement that may be appended to values.
If this parameter is omitted, then the plain property or qualifier value will be returned.short
(EXPENSIVE
when used)
Gets the short name (P1813) of any item returned if they have one attached. If that is not the case, then the default behaviour of returning the item label will occur.single
Returns only a single value instead of multiple (if multiple claims match). The returned value is the first match found from the best-ranked claims.mdy
Returns date values in month_day_year order instead of day_month_year order.- One of:
best
(default)preferred
normal
deprecated
Sets a rank constraint for the selected claims.
The latter three can be followed by a+
or a-
, e.g.normal+
orpreferred-
, where the first selects claims with a 'normal' rank or higher and the second selects claims with a 'preferred' rank or lower. To get claims of all ranks, usepreferred-
ordeprecated+
.
Output is always sorted from highest rank to lowest (regardless of this flag being set). - One of:
future
current
former
Sets a time constraint for the selected claims. Uses the claims' qualifiers of start time (P580) and end time (P582) to determine if the claim is valid for the selected time period. raw
Returns the raw value if applicable.
If this flag is used with item or property datatypes, then this will return the Q-identifier or P-identifier.
For quantity datatypes, this flag will strip off any units of measurement.
If this flag is used with time datatypes, then the returned date will be in the format ofyear-month-day
(e.g.1731-2-11
). Dates in the Julian calendar stored with a precision of days through millenniums will have/Julian
attached to the output (e.g.1731-2-11/Julian
, which may be split off using the{{#titleparts}}
template function).
If it is used with globe coordinate datatypes, then it replaces the various symbols with forward slashes in the returned value (e.g.52/5/3/N/4/19/3/E
, which may be split into parts using the{{#titleparts}}
template function).
Arguments
[edit source]property
[edit source]property | [<flags>] | [<item_id>] | <property_id>
<flags>
(optional)
A list of flags (see above).<item_id>
(optional,EXPENSIVE
when used)
Q-identifier of the item to be accessed (e.g. Q55).
If this parameter is omitted, then the item connected to the current page will be used.<property_id>
P-identifier or an available alias of the property to be accessed (e.g. P38).
qualifier
[edit source]qualifier | [<flags>] | [<item_id>] | <property_id> | [<claim_id_or_value>] | <qualifier_id>
<flags>
(optional)
A list of flags (see above).<item_id>
(optional,EXPENSIVE
when used)
Q-identifier of the item to be accessed (e.g. Q55).
If this parameter is omitted, then the item connected to the current page will be used.<property_id>
P-identifier or an available alias of the property to be accessed (e.g. P38).<claim_id_or_value>
(optional)
Either the Q-identifier of the particular claim to be accessed (e.g. Q6655) or a literal value (i.e. string or quantity etc., no item label) equal to the claim to be accessed.
Dates as literal values must be formattedyear-month-day
(e.g.1731-2-11
) for dates with a precision of days,year-month
(e.g.1731-2
) for dates with a precision of months, andyear
(e.g.1731
) for dates of lesser precision without any spaces or leading zeros. Dates BCE require a minus sign in front of the year (e.g.-2950-1-31
). Dates stored in the Julian calendar must have/Julian
attached to the end (e.g.1731-2-11/Julian
). Decades like the 2010s must be given as2010
(but the 2010s BCE as-2019
), centuries like the 20th century as1901
(but the 20th century BCE as-2000
), and millenniums like the 3rd millennium as2001
(but the 3rd millennium BCE as-3000
).
Globe coordinates as literal values must be formatted with forward slashes (i.e./
) between the parts and no symbols (e.g.52/5/3/N/4/19/3/E
) without any spaces or leading zeros.
The special type 'no value' can be given by entering the empty string (i.e.||
) and the special type 'unknown value' can be given by entering a space (i.e.|␣|
).
If this parameter is omitted, then all claims (matching any other constraints) within the property will be accessed.<qualifier_id>
P-identifier or an available alias of the qualifier to be accessed (e.g. P518).
propertyWithQualifier
[edit source]propertyWithQualifier | [<flags>] | [<item_id>] | <property_id> | [<claim_id_or_value>] | <qualifier_id>
This function is equivalent to qualifier
, except that the property is also returned with the qualifier between parentheses behind it.
label
[edit source]label | [<flags>] | [<item_or_property_id>]
<flags>
(optional)
A list of flags (see above).<item_or_property_id>
(optional)
Q-identifier of the item (e.g. Q55) or P-identifier (or an available alias) of the property (e.g. P38) to be accessed.
If this parameter is omitted, then the item connected to the current page will be used.
title
[edit source]title | [<flags>] | [<item_id>]
<flags>
(optional)
A list of flags (see above).<item_id>
(optional)
Q-identifier of the item to be accessed (e.g. Q55).
If this parameter is omitted, then the item connected to the current page will be used.
Named properties
[edit source]Named properties are aliases for P-identifiers. The following named properties (which are case-sensitive) are currently available:
Alias | translates to |
P-identifier |
---|---|---|
coord | → | P625 |
startTime | → | P580 |
endTime | → | P582 |
shortName | → | P1813 |
Examples
[edit source]property
[edit source]- Q55 (Template:Wikidataoi), P395 (Template:Wikidataoi): [string]
{{wikidataoi|property|Q55|P395}}
→ Template:Wikidataoi
- Q55 (Template:Wikidataoi), P1549 (Template:Wikidataoi): [monolingual text]
{{wikidataoi|property|Q55|P1549}}
→ Template:Wikidataoi
If the template is transcluded on the Template:Wikidataoi page (which is linked to Q55), then the Q55
can be omitted:
- P1549 (Template:Wikidataoi): [monolingual text]
{{wikidataoi|property|P1549}}
→ Template:Wikidataoi
property with rank
[edit source]- Q55 (Template:Wikidataoi), P38 (Template:Wikidataoi): [item label]
- best rank (default)
{{wikidataoi|property|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|raw|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|raw|linked|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|best|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|best|linked|Q55|P38}}
→ Template:Wikidataoi
- other ranks
{{wikidataoi|property|preferred|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|preferred-|linked|Q55|P38}}
→ Template:Wikidataoi
{{wikidataoi|property|normal+|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|normal|Q55|P38}}
→ Template:Wikidataoi
property with time constraint
[edit source]- Q55 (Template:Wikidataoi), P38 (Template:Wikidataoi): [item label]
{{wikidataoi|property|normal+|current|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|normal+|former|Q55|P38}}
→ Template:Wikidataoi
property with short name
[edit source]- Q55 (Template:Wikidataoi), P38 (Template:Wikidataoi): [item label]
{{wikidataoi|property|normal|current|short|Q55|P38}}
→ Template:Wikidataoi{{wikidataoi|property|normal|current|short|linked|Q55|P38}}
→ Template:Wikidataoi
property with return of quantity
[edit source]- Q55 (Template:Wikidataoi), P2884 (Template:Wikidataoi): [quantity]
{{wikidataoi|property|Q55|P2884}}
→ Template:Wikidataoi{{wikidataoi|property|linked|Q55|P2884}}
→ Template:Wikidataoi{{wikidataoi|property|raw|Q55|P2884}}
→ Template:Wikidataoi
property with return of globe coordinate
[edit source]- Q55 (Template:Wikidataoi), P625 (Template:Wikidataoi): [globe coordinate]
{{wikidataoi|property|Q55|P625}}
→ Template:Wikidataoi{{wikidataoi|property|linked|Q55|P625}}
→ Template:Wikidataoi{{wikidataoi|property|raw|Q55|P625}}
→ Template:Wikidataoi
A named property (or alias) can be used instead of the P-identifier:
- Q55 (Template:Wikidataoi), "coord" (→ P625, Template:Wikidataoi): [globe coordinate]
{{wikidataoi|property|Q55|coord}}
→ Template:Wikidataoi
property with return of single value
[edit source]- Q55 (Template:Wikidataoi), P150 (Template:Wikidataoi): [item label]
{{wikidataoi|property|Q55|P150}}
→ Template:Wikidataoi{{wikidataoi|property|single|Q55|P150}}
→ Template:Wikidataoi
qualifier
[edit source]- Q55 (Template:Wikidataoi), P1343 (Template:Wikidataoi), Q302556 (Template:Wikidataoi), P958 (Template:Wikidataoi): [string]
{{wikidataoi|qualifier|Q55|P1343|Q302556|P958}}
→ Template:Wikidataoi
If the template is transcluded on the Template:Wikidataoi page (which is linked to Q55), then the Q55
can be omitted:
- P1343 (Template:Wikidataoi), Q302556 (Template:Wikidataoi), P958 (Template:Wikidataoi): [string]
{{wikidataoi|qualifier|P1343|Q302556|P958}}
→ Template:Wikidataoi
qualifier with rank
[edit source]- Q55 (Template:Wikidataoi), P38 (Template:Wikidataoi), P518 (Template:Wikidataoi): [item label]
- best rank (default)
{{wikidataoi|qualifier|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|raw|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|raw|linked|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|best|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|best|linked|Q55|P38|P518}}
→ Template:Wikidataoi
- other ranks
{{wikidataoi|qualifier|preferred|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|preferred-|linked|Q55|P38|P518}}
→ Template:Wikidataoi
{{wikidataoi|qualifier|normal+|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|normal|Q55|P38|P518}}
→ Template:Wikidataoi
qualifier with time constraint
[edit source]- Q55 (Template:Wikidataoi), P38 (Template:Wikidataoi), P518 (Template:Wikidataoi): [item label]
{{wikidataoi|qualifier|normal+|current|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|normal+|former|Q55|P38|P518}}
→ Template:Wikidataoi
qualifier with claim ID
[edit source]- Q55 (Template:Wikidataoi), P38 (Template:Wikidataoi), Q4917 (Template:Wikidataoi), P518 (Template:Wikidataoi): [item label]
{{wikidataoi|qualifier|Q55|P38|Q4917|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|linked|Q55|P38|Q4917|P518}}
→ Template:Wikidataoi
qualifier with literal value
[edit source]- Q55 (Template:Wikidataoi), P2884 (Template:Wikidataoi), 230 volt, P2144 (Template:Wikidataoi): [quantity]
{{wikidataoi|qualifier|Q55|P2884|230|P2144}}
→ Template:Wikidataoi{{wikidataoi|qualifier|linked|Q55|P2884|230|P2144}}
→ Template:Wikidataoi{{wikidataoi|qualifier|raw|Q55|P2884|230|P2144}}
→ Template:Wikidataoi
qualifier with return of time
[edit source]- Q55 (Template:Wikidataoi), P463 (Template:Wikidataoi), Q458 (Template:Wikidataoi), P580 (Template:Wikidataoi): [time]
{{wikidataoi|qualifier|Q55|P463|Q458|P580}}
→ Template:Wikidataoi{{wikidataoi|qualifier|mdy|Q55|P463|Q458|P580}}
→ Template:Wikidataoi{{wikidataoi|qualifier|raw|Q55|P463|Q458|P580}}
→ Template:Wikidataoi
qualifier with return of single value
[edit source]- Q55 (Template:Wikidataoi), P2855 (Template:Wikidataoi), P518 (Template:Wikidataoi): [item label]
{{wikidataoi|qualifier|Q55|P2855|P518}}
→ Template:Wikidataoi{{wikidataoi|qualifier|single|Q55|P2855|P518}}
→ Template:Wikidataoi
propertyWithQualifier
[edit source]- Q55 (Template:Wikidataoi), P2884 (Template:Wikidataoi), P2144 (Template:Wikidataoi): [quantity]
{{wikidataoi|propertyWithQualifier|Q55|P2884|P2144}}
→ Template:Wikidataoi{{wikidataoi|propertyWithQualifier|linked|Q55|P2884|P2144}}
→ Template:Wikidataoi{{wikidataoi|propertyWithQualifier|raw|Q55|P2884|P2144}}
→ Template:Wikidataoi
- Q55 (Template:Wikidataoi), P38 (Template:Wikidataoi), P518 (Template:Wikidataoi): [item label]
{{wikidataoi|propertyWithQualifier|normal+|current|Q55|P38|P518}}
→ Template:Wikidataoi{{wikidataoi|propertyWithQualifier|normal+|current|short|linked|Q55|P38|P518}}
→ Template:Wikidataoi
If the template is transcluded on the Template:Wikidataoi page (which is linked to Q55), then the Q55
can be omitted:
- P38 (Template:Wikidataoi), P518 (Template:Wikidataoi): [item label]
{{wikidataoi|propertyWithQualifier|normal+|current|P38|P518}}
→ Template:Wikidataoi
label
[edit source]{{wikidataoi|label|Q4917}}
→ Template:Wikidataoi
{{wikidataoi|label|linked|Q4917}}
→ Template:Wikidataoi
{{wikidataoi|label|short|Q4917}}
→ Template:Wikidataoi
{{wikidataoi|label|short|linked|Q4917}}
→ Template:Wikidataoi
{{wikidataoi|label|raw|Q4917}}
→ Template:Wikidataoi
{{wikidataoi|label|raw|linked|Q4917}}
→ Template:Wikidataoi
{{wikidataoi|label|P38}}
→ Template:Wikidataoi
{{wikidataoi|label|linked|P38}}
→ Template:Wikidataoi
{{wikidataoi|label|raw|P38}}
→ Template:Wikidataoi
{{wikidataoi|label|raw|linked|P38}}
→ Template:Wikidataoi
{{wikidataoi|label|Q776}}
→ Template:Wikidataoi{{wikidataoi|label|linked|Q776}}
→ Template:Wikidataoi
If the template is transcluded on the Template:Wikidataoi page (which is linked to Q776), then the Q776
can be omitted:
{{wikidataoi|label}}
→ Template:Wikidataoi
title
[edit source]{{wikidataoi|title|Q776}}
→ Template:Wikidataoi{{wikidataoi|title|linked|Q776}}
→ Template:Wikidataoi{{wikidataoi|title|raw|Q776}}
→ Template:Wikidataoi{{wikidataoi|title|raw|linked|Q776}}
→ Template:Wikidataoi
If the template is transcluded on the Template:Wikidataoi page (which is linked to Q776), then the Q776
can be omitted:
{{wikidataoi|title}}
→ Template:Wikidataoi
See also
[edit source]- Module:Wd, the source module that is called by this template.