"વિભાગ:Wikidata/doc" ની આવૃત્તિઓ વચ્ચેનો તફાવત

Undid revision 1008258690 by 1.127.104.10 (talk)
નાનું (Bot: Replace deprecated <source> tag and "enclose" parameter [https://lists.wikimedia.org/pipermail/wikitech-ambassadors/2020-April/002284.html])
(Undid revision 1008258690 by 1.127.104.10 (talk))
{{Ombox|image=[[Image:Stop hand nuvola.svg|40px]]|type=delete|text=[[Module:Wikidata]] is [[deprecation|deprecated]]. Please use [[Module:WikidataIB]] or [[Module:Wd]] instead.}}
{{module rating|protected}}
{{High-use}}
This module is a modification of the original at [[Module:Sandbox/Tom Morris]] which was created 19 May 2013.
 
== Methods ==
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:
* <code>getValue</code>: Returns wiki-linked values, if applicable. All other values will be output similar to <code><nowiki>{{#property:}}</nowiki></code>, except that if values with preferred rank exist, then only they are returned. Unlike <code>formatStatements</code> from [[:w:ru:Модуль:Wikidata]], <code>getValue</code> does not yet pick up any references (see [[:w:en:Module talk:Wikidata/Archive 1#Why the references from Wikidata get dropped?]]).
* <code>getRawValue</code>: 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 <code><nowiki>{{#property:}}</nowiki></code>, including normal values, even if preferred values exist.
* <code>getDateValue</code>: 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.
 
Other methods:
* <code>pageId</code>: returns the Wikidata id (Q…) of the current page or nothing if the page is not connected to Wikidata. To get the Wikidata id of another page, use [[Module:ResolveEntityId|<nowiki>{{#invoke:ResolveEntityId|</nowiki>''page''<nowiki>}}</nowiki>]].
* <code>getTAValue</code>: gets the TA98 (Terminologia Anatomica first edition 1998) values for property P1323. It takes no parameters and constructs its output as a list, with each value linked to an external resource. This is an exemplar for writing calls that need to return external links.
* <code>ViewSomething</code>: gets anything in the structured data, including labels, descriptions, references and interwiki links. See [https://en.wikipedia.org/w/index.php?title=Module_talk%3AWikidata&diff=652812891&oldid=650633541#Is_it_possible_to_get_value.28s.29_in_structured_tree_by_this_Module.3F]
* <code>getSiteLink</code>: gets name of a page in given in argument wiki (like "enwikiquote" for English Wikiquote, "arwiki" for the Arabic Wikipedia).
* <code>Dump</code>: <code><nowiki>{{#invoke:Wikidata|Dump|claims}}</nowiki></code> spies the structured data. It uses the same arguments as ViewSomething. Try this with preview only to see results. That helps you a lot in developing Lua scripts that access the data. If used without arguments, it dumps everything including labels, descriptions, references and interwiki links. SeeThere [https://en.wikipedia.org/w/index.php?title=Module_talk%3AWikidata&diff=652812891&oldid=650633541#Is_it_possible_to_get_value.28s.29_in_structured_tree_by_this_Moduleis the wrapper template, see {{tl|Dump}}.3F]
* <code>getImageLegend</code>: returns an image legend (image is property P18; image legend is property P2096).
*: Call as <code><nowiki>{{#invoke:Wikidata |getImageLegend | <PARAMETER> | lang=<ISO-639code> |id=<QID>}}</nowiki></code>
will do the same as getValue, but takes an extra parameter, which is the QID of the Wikidata item that you want to get the property value from.
For example:
* <code><nowiki>{{#invoke:Wikidata|getValueFromID|Q151973|P26|FETCH_WIKIDATA}}</nowiki></code>
will fetch a list of the linked values for 'spouse' (P26) from 'Richard Burton' (Q151973) from anywhere in the English Wikipedia.
 
Anonymous user