Content deleted Content added
→Examples: separate lines a little |
update documentation |
||
Line 8:
<nowiki>{{#invoke:WikidataIB |getValue |<PropertyID> |name=<fieldname> |suppressfields=<list of fields which will never display> |fetchwikidata=<list of fields to fetch values from Wikidata> |<local parameter>}}</nowiki>
<nowiki>{{#invoke:WikidataIB |getCoords |name=<fieldname> |suppressfields=<list of fields which will never display> |fetchwikidata=<list of fields to fetch values from Wikidata> |<local parameter>}}</nowiki>
* The module provides one call at present: <code>getValue</code>▼
* getValue can take a named parameter {{para|qid}} which is the Wikidata ID for the article. This will not normally be used but is available for testing, although it makes the call ''expensive''.▼
▲
* The name of the field that this function is called from is passed in the named parameter {{para|name}}, which is first checked against a blacklist of fields that are never to be displayed, (i.e. the call must return nil in all circumstances). If the fiels is not on the blacklist, it is then checked against a whitelist. If the name of the field matches, the call will return any locally supplied value if it is supplied as the second unnamed parameter, or the Wikidata value otherwise.▼
=== Function getValue ===
▲* getValue can also take a named parameter {{para|qid}} which is the Wikidata ID for the article. This will not normally be used but is available for testing, although it makes the call ''expensive''.
* The property to be returned is passed in the first unnamed property.
▲* The name of the field that this function is called from is passed in the named parameter {{para|name}}, which is first checked against a blacklist of fields that are never to be displayed, (i.e. the call must return nil in all circumstances). If the
* The name is compulsory when the blacklist or whitelist is used, so the module returns nil if it is not supplied.
* The blacklist is passed in the named parameter {{para|suppressfields}}
* The whitelist is passed in the named parameter {{para|fetchwikidata}}
=== Function getCoords ===
* getCoords can also take a named parameter {{para|qid}} which is the Wikidata ID for the article. This will not normally be used but is available for testing, although it makes the call ''expensive''.
* The coordinates from Wikidata are parsed and passed to [[Template:Coord]] which returns the display as if it were called manually.
* The name of the field that this function is called from is passed in the named parameter {{para|name}}, which is first checked against a blacklist of fields that are never to be displayed, (i.e. the call must return nil in all circumstances). If the field is not on the blacklist, it is then checked against a whitelist. If the name of the field matches, the call will return any locally supplied value if it is supplied as the unnamed parameter, or the Wikidata value otherwise.
* The name is compulsory when the blacklist or whitelist is used, so the module returns nil if it is not supplied.
* The blacklist is passed in the named parameter {{para|suppressfields}}
Line 29 ⟶ 44:
As a shorthand, {{para|fetchwikidata|ALL}} will fetch all of the fields that are not blacklisted, as long as no local value is already provided in the article for a given field.
The getCoords call will display the output of [[Template:Coord]] when supplied with the coordinates returned from Wikidata.There's an example in [[Template:Sandbox/Infobox biosphere reserve]] where it's coded like this:
<pre style="line-height:1.2em;">
|label20 = Coordinates
| data20 = {{#invoke:WikidataIB |getCoords |name=coordinates |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |{{{coordinates|}}} }}
</pre>
=== Upgrading existing infoboxes ===
|