Content deleted Content added
update documentation |
|||
Line 5:
The module "{{BASEPAGENAME}}" contains the following methods, that allow the calling script to retrieve the value for any property from Wikidata by supplying the property ID as the first parameter:
* <tt>getValue</tt>: Returns wiki-linked values, if applicable. All other values will be output similar to <tt><nowiki>{{#property:}}</nowiki></tt>, except that if values with preferred rank exist, then only they are returned. Unlike <tt>formatStatements</tt> from [[:ru:Модуль:Wikidata]], <tt>getValue</tt> does not yet pick up any references (see [[Module talk:Wikidata#Why the references from Wikidata get dropped?]]).
* <tt>getRawValue</tt>: Returns non-linked property values and numbers with the thousand separator. It also returns the plain numeric value of a property which is a quantity. All other values will be output similar to <tt><nowiki>{{#property:}}</nowiki></tt>, including normal values, even if preferred values exist.
* <tt>getDateValue</tt>: Special method to return formatted dates. The default date format is [day month year]; an optional third parameter can be added for other date formats: for [month day, year], add "mdy"; for [month year], add "my"; for year only, add "y". A further optional parameter, which must be fourth, such as "BCE", may be added to override the default "BC" that is suffixed for dates BC.
* <tt>getImages</tt>: Returns all of the images of a particular property, e.g. image (P18), Gene Atlas Image (P692), etc. Parameters are <code>| propertyID | value / FETCH_WIKIDATA / nil | separator (default=space) | size (default=220px)</code>. The returned text will be in the format <nowiki>[[File:Filename | size]]</nowiki> for each image with a selectable size and separator (which may be html). If a property is supplied that is not of type "commonsMedia", it will return empty text.
* <tt>getUnits</tt> This takes a propertyID which is a quantity as the first parameter, and returns the name of the units that the property is using on the current page. It returns empty if the property is not a quantity type or if the value is not set. The second parameter may be used to override fetching from Wikidata, if it is anything other than "FETCH_WIKIDATA".
* <tt>getUnitID</tt> This takes a propertyID which is a quantity as the first parameter, and returns the QID of the units that the property is using on the current page. It returns empty if the property is not a quantity type or if the value is not set. The second parameter may be used to override fetching from Wikidata, if it is anything other than "FETCH_WIKIDATA".
Wikidata qualifier values (if present) can be retrieved by the following methods:
|