Wikidata/Notes/Inclusion syntax v0.4
This page is currently a draft. More information pertaining to this may be available on the talk page. Translation admins: Normally, drafts should not be marked for translation. |
This page describes the data inclusion syntax for the Wikibase client, by which the properties of data items can be included and rendered on a wiki page using templates. In short: This is how we want Wikipedia articles to include data from Wikidata.
The inclusion syntax presented here is meant to work for very simple cases, and only for them.
Complicated cases are to be realized using Lua.
Accessing Item Data
editProperties
editProperties of a Wikidata Item can be used via the #property parser function:
{{#property:P36}} {{#property:capital}}
This will provide a representation of the value of the capital
property of the page's default item. The default item is the Wikidata item that is associated with this page via language links.
The property label is case-sensitive. It is also possible to use the identifier of the property (this is more stable against changes in the label of a property).
Properties of different items
editTo access the properties of a different item, it has to be specified explicitly by its ID. (This was implemented in phab:T49930.)
{{#property:P36|from=Q183}}
→ Berlin{{#property:capital|from=Q183}}
→ Berlin
Specification of the item by its Wikipedia title is not implemented yet:
{{#property:P36|from=Germany}}
→{{#property:capital|from=Germany}}
→However, using Scribunto, msg = mw.message.newRawMessage("{{#property: capital}}"): title("Germany"):text() will return "Bonn, Berlin" from any page. (Presently this result will not be updated when the Wikidata entry is updated)This workaround has been intentionally rendered inoperative.[1] You can use Wikidata if you run an external site that is free to make use of its API.- Another workaround: Scribunto function mw.wikibase.getEntityIdForTitle (not implemented yet - phab:T74815)
Property rank and multiple values
editIf a Wikidata property value has a "deprecated rank", {{#property:}} will not display it:
- Robert Leroux (Q25899) has databaseOlympics.com athlete ID (archived) (P3520) value LEROUROB01 (deprecated rank)
{{#property:P3520|from=Q25899}}
→ LEROUROB01
- Robert Leroux (Q25899) has ISNI (P213) value 0000 0004 3980 4014 (normal rank)
{{#property:P213|from=Q25899}}
→ 0000000439804014
If a Wikidata property has multiple values, {{#property:}} will only display the highest ranked values:
- Janet Gaynor (Q182462) has Internet Broadway Database person ID (P1220) values 41898 (preferred rank) and 80344 (normal rank)
{{#property:P1220|from=Q182462}}
→ 41898
- Cathy Rigby (Q2894503) has Internet Broadway Database person ID (P1220) values 57807 and 69418 (both normal rank)
{{#property:P1220|from=Q2894503}}
→ 57807, 69418
Check the existence of the property
editCheck whether the property exists on wikidata to display an infobox using #if:
- Commons category of mixing console (Q654117)
{{#property:P373|from=Q654117}}
→ Audio mixers, Audio consoles
- Display the main category with a link from an infobox in Wikipedia if that property exists
{{#if:{{#property:P373|from=Q654117}}|[[:commons:Category:{{#property:P373|from=Q654117}}]]}}
→ commons:Category:Audio mixers, Audio consoles
Work in progress
editThis page is outdated, but if it was updated, it might still be useful. Please help by correcting, augmenting and revising the text into an up-to-date form. |