Jump to content

Module:Wikidata/doc

विकिपीडिया से
RexxS (बातचीत | योगदान) (update documentation to note returning empty string if wikidata has no value) के द्वारा 19:09, 25 अगस्त 2013 के बदलाव

This module is a cosmetic modification of the original at Module:Sandbox/Tom Morris which was created 19 May 2013.

The module "Wikidata" contains one available call (getSpouse) that allows the calling script to retrieve the value for spouse (property P26) from Wikidata.

If the spouse property is not defined in Wikidata for the article that invokes this code, then an empty string ("") is returned.

Usage

  • {{#invoke:{{BASEPAGENAME}}|getSpouse|}} = returns nothing, so suppresses the display of spouse in an infobox
  • {{#invoke:{{BASEPAGENAME}}|getSpouse|FETCH_WIKIDATA}} = returns the linked value(s) of property P26 (spouse) stored in wikidata for the corresponding article (e.g. for article Bill Clinton, it returns Hillary Rodham Clinton)
  • {{#invoke:{{BASEPAGENAME}}|getSpouse|[[Hillary Clinton]]}} = returns Hillary Clinton, allowing an infobox to use a local value rather than the value stored in Wikidata.

Inside an infobox definition, it may be called like this:

  • | data55 = {{#invoke:{{BASEPAGENAME}}|getSpouse|{{{spouse|FETCH_WIKIDATA}}} }}

which causes the infobox to:

  1. not display spouse if the infobox parameter |spouse is not supplied
  2. display the linked value(s) from Wikidata if the infobox parameter |spouse is set to be blank (as "| spouse ="}
  3. display the local infobox parameter |spouse if it is supplied (e.g. "|spouse = Hillary Clinton")

Parameters

  • A single, unnamed parameter is supplied. This may be null, "FETCH_WIKIDATA", or any other string (within the module it is assigned to the local variable spouse_input)

Examples

Testing: Copy and paste the following into any article and preview it (please don't save!):

* - {{#invoke:Sandbox/RexxS|getSpouse|}}
* - {{#invoke:Sandbox/RexxS|getSpouse|FETCH_WIKIDATA}}
* - {{#invoke:Sandbox/RexxS|getSpouse|[[Hillary Clinton]]}}

In Bill Clinton you should get:


In Barack Obama you should get:


In Richard Burton you should get:


In Franz Kafka]] you should get: