Module talk:WikidataIB: Difference between revisions

Content deleted Content added
 
(1,000 intermediate revisions by 78 users not shown)
Line 1:
{{Permanently protected}}
== Testing ==
{{WPBS|
 
{{WikiProject Wikidata}}
Let's see how this would work in [[Animal farm]], [[d:Q1396889]].
 
=== Local parameter ===
<pre>
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |Fred Bloggs}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=author; number_of_pages |name=author}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=author; number_of_pages; |name=author |Freda Bloggs}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=author; number_of_pages |name=author |suppressfields=author}}<
</pre>
 
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |Fred Bloggs}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=author; number_of_pages |name=author}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=author; number_of_pages; |name=author |Freda Bloggs}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=author; number_of_pages |name=author |suppressfields=author}}<
 
=== Only sourced ===
<pre>
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |onlysourced=no}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |onlysourced=yes}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |name=awards |onlysourced=}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |name=awards |onlysourced=no}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |name=awards |onlysourced=yes}}<
</pre>
 
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |onlysourced=no}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |onlysourced=yes}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |name=awards |onlysourced=}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |name=awards |onlysourced=no}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |name=awards |onlysourced=yes}}<
 
=== No icon ===
<pre>
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |noicon=}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |noicon=no}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |noicon=yes}}<
</pre>
 
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |noicon=}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |noicon=no}}<
# >{{#invoke:WikidataIB |getValue |qid=Q1396889 |P50 |fetchwikidata=ALL |name=author |noicon=yes}}<
 
== Coordinates ==
 
Just to note that it would be nice to be able to set the coordinates to display both inline and in the title (passing "|display=inline,title" to {{tl|coord}}); this module just seems to allow inline coordinates. Thanks. [[User:Mike Peel|Mike Peel]] ([[User talk:Mike Peel|talk]]) 17:37, 18 December 2016 (UTC)
 
: {{reply to |Mike Peel|label=Mike}} I've implemented the 'display' parameter now. This is how it would work in {{q|Q592248}}:
:* <code><nowiki>{{#invoke:WikidataIB |getCoords |qid=Q592248 |name=coord |fetchwikidata=ALL}}</nowiki></code> → {{#invoke:WikidataIB |getCoords |qid=Q592248 |name=coord |fetchwikidata=ALL}}
: You should see 31°57′30″N 111°35′48″W in the title position of this page as well.
: You can't see multiple examples because the of title coordinates.
: If you want to test the "title" or "inline" values, change the above to
:* <code><nowiki>{{#invoke:WikidataIB |getCoords |qid=Q592248 |display=title |name=coord |fetchwikidata=ALL}}</nowiki></code>
:* <code><nowiki>{{#invoke:WikidataIB |getCoords |qid=Q592248 |display=inline |name=coord |fetchwikidata=ALL}}</nowiki></code>
: Of course, you don't need this so much now that the coord templates are Wikidata-aware, but it's useful if you want to implement the white/blacklists. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 11:55, 16 January 2017 (UTC)
 
== Format Dates ==
Some test cases for the function formatDate. Call like <code><nowiki>{{#invoke:WikidataIB |formatDate | 1 August 30 BCE |bc=BCE |df=dmy}}</nowiki></code>
{| class="wikitable" style="width:24em;"
|+ Input date: 1 August 30 BCE, 12:39:56
|-
| no parameters || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56}}
|-
| bc=BC || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC}}
|-
| bc=BCE || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE}}
|-
| bc=bc || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=bc}}
|-
| bc=bce || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=bce}}
|-
| bc=XYZ || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 | bc=XYZ}}
|-
| df=dmy || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |df=dmy}}
|-
| df=DMY || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |df=DMY}}
|-
| df=mdy || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |df=mdy}}
|-
| df=MDY || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |df=MDY}}
|-
| df=ABC || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |df=ABC}}
|-
| df=y || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |df=y }}
|-
| bc=BCE df=dmy || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=mdy || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=y || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE |df=y}}
|-
| bc=BC df=dmy || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC |df=dmy}}
|-
| bc=BC df=mdy || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC |df=mdy}}
|-
| bc=BC df=y || {{#invoke:WikidataIB |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC |df=y}}
|}
 
{| class="wikitable" style="width:24em;"
|+ Input date: 20 January 2017, 12:39:56
|-
| no parameters || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56}}
|-
| bc=BC || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BC}}
|-
| bc=BCE || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BCE}}
|-
| bc=bc || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=bc}}
|-
| bc=bce || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=bce}}
|-
| bc=XYZ || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 | bc=XYZ}}
|-
| df=dmy || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |df=dmy}}
|-
| df=DMY || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |df=DMY}}
|-
| df=mdy || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |df=mdy}}
|-
| df=MDY || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |df=MDY}}
|-
| df=ABC || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |df=ABC}}
|-
| df=y || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |df=y }}
|-
| bc=BCE df=dmy || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=mdy || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=y || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BCE |df=y}}
|-
| bc=BC df=dmy || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BC |df=dmy}}
|-
| bc=BC df=mdy || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BC |df=mdy}}
|-
| bc=BC df=y || {{#invoke:WikidataIB |formatDate | 20 January 2017, 12:39:56 |bc=BC |df=y}}
|}
 
Some test cases for the function formatDate. Call like <code><nowiki>{{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE |bc=BCE |df=dmy}}</nowiki></code>
{| class="wikitable" style="width:24em;"
|+ Input date: 1 August 30 BCE, 12:39:56
|-
| no parameters || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56}}
|-
| bc=BC || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC}}
|-
| bc=BCE || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE}}
|-
| bc=bc || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=bc}}
|-
| bc=bce || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=bce}}
|-
| bc=XYZ || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 | bc=XYZ}}
|-
| df=dmy || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |df=dmy}}
|-
| df=DMY || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |df=DMY}}
|-
| df=mdy || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |df=mdy}}
|-
| df=MDY || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |df=MDY}}
|-
| df=ABC || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |df=ABC}}
|-
| df=y || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |df=y }}
|-
| bc=BCE df=dmy || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=mdy || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=y || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BCE |df=y}}
|-
| bc=BC df=dmy || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC |df=dmy}}
|-
| bc=BC df=mdy || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC |df=mdy}}
|-
| bc=BC df=y || {{#invoke:WikidataIB/sandbox |formatDate | 1 August 30 BCE, 12:39:56 |bc=BC |df=y}}
|}
 
{| class="wikitable" style="width:24em;"
|+ Input date: 20 January 2017, 12:39:56
|-
| no parameters || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56}}
|-
| bc=BC || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BC}}
|-
| bc=BCE || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BCE}}
|-
| bc=bc || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=bc}}
|-
| bc=bce || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=bce}}
|-
| bc=XYZ || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 | bc=XYZ}}
|-
| df=dmy || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |df=dmy}}
|-
| df=DMY || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |df=DMY}}
|-
| df=mdy || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |df=mdy}}
|-
| df=MDY || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |df=MDY}}
|-
| df=ABC || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |df=ABC}}
|-
| df=y || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |df=y }}
|-
| bc=BCE df=dmy || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=mdy || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BCE |df=dmy}}
|-
| bc=BCE df=y || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BCE |df=y}}
|-
| bc=BC df=dmy || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BC |df=dmy}}
|-
| bc=BC df=mdy || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BC |df=mdy}}
|-
| bc=BC df=y || {{#invoke:WikidataIB/sandbox |formatDate | 20 January 2017, 12:39:56 |bc=BC |df=y}}
|}
 
=== Calls to getValue for dates ===
Some calls to getValue that return dates:
* In {{q|Q357585}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q357585 |P569 |fetchwikidata=ALL}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q357585 |P569 |fetchwikidata=ALL}}
* In {{q|Q51673}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL}}
* In {{q|Q51673}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL |bc=BC}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL |bc=BC}}
* In {{q|Q51673}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL |df=mdy}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL |df=mdy}}
* In {{q|Q51673}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL |df=y}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q51673 |P569 |fetchwikidata=ALL |df=y}}
* In {{q|Q151973}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL}}
* In {{q|Q151973}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL |bc=BC}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL |bc=BC}}
* In {{q|Q151973}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL |df=mdy}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL |df=mdy}}
* In {{q|Q151973}}: <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL |df=y}}</nowiki></code> -> {{#invoke:WikidataIB |getValue |qid=Q151973 |P569 |fetchwikidata=ALL |df=y}}
 
== Can't get this working ==
 
{{Wikidata property|P176}}
About [[:en:Prussian P 10]], item: {{Q|Q882458}}. It has P176=Borsig (Company). So Wikidata seems OK.
 
In this case I test:
-<nowiki>{{#invoke:WikidataIB|getValue|qid=Q882458|P176}}</nowiki>-
Returns empty string: -{{#invoke:WikidataIB|getValue|qid=Q882458|P176}}-
 
Also, when previewing in article page itself (no {{para|qid}} used), it returns a blank. Am I missing something? -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 17:32, 15 January 2017 (UTC)
 
: {{reply to |DePiep}} Remember that this is designed for use in an infobox, therefore there are extra parameters that have to be enabled otherwise it won't return anything. The call matches the name of the field you're using it in with a list of fields that are to enabled ("whitelisted"). What you call the field doesn't matter as long as it's on the whitelist. So you can use:
:* <code><nowiki>{{#invoke:WikidataIB |getValue |qid=Q882458 |P176 |name=def |fetchwikidata=abd, def, ghi, jkl, etc}}</nowiki></code> → {{#invoke:WikidataIB |getValue |qid=Q882458 |P176 |name=def |fetchwikidata=abd, def, ghi, jkl, etc}}
: And it will return {{Q|P176}} for {{Q|Q882458}}. I'll miss out the qid in the first part of the following examples as you won't need it other than for testing on pages like this.
: Rather than having to list every fieldname on the whitelist, you can use "ALL". So the call you probably want is something like:
:* <code><nowiki>{{#invoke:WikidataIB |getValue |P176 |name=manufacturer |fetchwikidata=ALL}}</nowiki></code> → {{#invoke:WikidataIB |getValue |qid=Q882458 |P176 |name=manufacturer |fetchwikidata=ALL}}
: Although if you're designing an infobox, you'll probably want to pass the whitelist (and blacklist) as parameters so the article editor supplies them once and the infobox passes them to each call in the design. Lets say we give them the names {{para|whitelist}} and {{para|blacklist}}. Then the code in the infobox design for the 'Manufacturer' field would be:
:* <code><nowiki>{{#invoke:WikidataIB |getValue |P176 |name=manufacturer |fetchwikidata={{{whitelist|}}} |suppressfields={{{blacklist|}}} |{{{manufacturer|}}} }}</nowiki></code>
: The second unnamed parameter allows a local parameter (called 'manufacturer' in this case) to override the Wikidata call as ususal.
: The infobox in use in an article could look something as simple as:
<pre style="margin-left:1.7em; line-height:1.2em;">
{{infobox something
| whitelist = ALL
}}
{{banner holder|text=Page history|1=
</pre>
{{oldtfdfull|date= 2020 September 15 |result=keep |disc=Module:Wikidata Infobox}}
: Does that make sense? Let me know if you're still having problems. Cheers --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 02:03, 16 January 2017 (UTC)
::Thanks, will process this. Could this be in the documentation? Sort of basic "required parameters" list? To me, the description & examples there are already quite abstract (into high end usage). Quite an object that requires studying. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 09:16, 16 January 2017 (UTC)
 
== Date handling ==
 
If more extensive date handling is ever needed, consider [[Module:Date]] which can parse dates in various formats, including a Wikidata date, and perform date arithmetic. However, the module is limited to four-digit years. The template {{tl|extract}} can be used for quick tests although it does not expose options to choose the BC/BCE format.
*<code><nowiki>{{extract|+2016-06-21T14:30:00Z}}</nowiki></code> → {{extract|+2016-06-21T14:30:00Z}}
*<code><nowiki>{{extract|+2016-06-21T14:30:00Z|show=ymd}}</nowiki></code> → {{extract|+2016-06-21T14:30:00Z|show=ymd}}
[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:41, 20 January 2017 (UTC)
:
: Thanks {{u|Johnuniq|John}}. I think I had most of that functionality, as well as the BC/BCE and dmy/mdy/y functionality in [[Module:Wikidata]] in the getDateValue function, which dealt with any date BC or AD - I needed that for dob of notable Romans, etc. although the code was hard to read because I was using the timestamp and manipulating that directly. For greater flexibility in this module, I decided to use the mw.wikibase.formatPropertyValues() function – which always returns dmy format dates with BCE as appropriate – because that can be used on properties that are qualifiers as well. I'll need that later as fewer properties are defined and more values are stored as properties of qualifiers (like property:creator - qualifier:has role - item:video game artist instead of property:video game artist). Things like marriages have start-date and end-date that are in qualifiers. Anyway, I think I've managed to create a local function that takes the date in dmy+BCE format and outputs it in whatever format is wanted for use in article infoboxes. I've put a wrapper around it so that it's exported and can be invoked. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 04:00, 21 January 2017 (UTC)
::Good, and I'm sure Wikidata has many quirks which require dedicated code. I just wanted to say that if more stuff such as date differences or adding time deltas were ever needed, Module:Date is available. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:59, 21 January 2017 (UTC)
 
== Bug in fetching referenced data ==
 
At [[Edward Bergh]] I added a second date at [[d:Q5572078]] with year-only accuracy, as that's what I can easily find a reference for atm. Now that there's a reference, it displays the date in the infobox. However, it fetches the *unreferenced* date (with day-accuracy) rather than the referenced one (with year-accuracy). Not a big deal, since [https://www.wikidata.org/w/index.php?title=Q5572078&diff=437849800&oldid=437848585 changing the rank] causes the correct one to show, but this is probably an edge-case that should be fixed ({{ping|RexxS|p=}}). Thanks. [[User:Mike Peel|Mike Peel]] ([[User talk:Mike Peel|talk]]) 16:35, 28 January 2017 (UTC)
: (Note: I've found a ref for the day-accuracy one, so I've now removed the year-accuracy one from the entry, but this can be found in the history. Thanks. [[User:Mike Peel|Mike Peel]] ([[User talk:Mike Peel|talk]]) 16:39, 28 January 2017 (UTC)
::
:: Thanks, {{u|Mike Peel|Mike}}. I'll have a think about how best to solve this issue. I originally thought that allowing date format to be set to "y" in the article would be enough, but sometimes there are two different date fields displayed with different precisions. It would be a shame to have to import the hugely complex date parsing code from Module:Wikidata that works from the raw timestamp just to ensure that we can respect the precision set by an referenced date. In many ways, the rank system at Wikidata is the "proper" solution – because a referenced date is always going to be preferred to an unreferenced one, and it makes that clear to other users of the Wikidata – but I know that we'd all prefer not to have to do that manually. Maybe a bot could be run on Wikidata which changed the rankings of unsourced statements to be lower than those of sourced ones? Can you see any downside in that? --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 18:17, 28 January 2017 (UTC)
::: I think this is just a question of how the code should select which value to use, rather than having to affect the date formatting code. This could easily happen with a plain-text/Q-linked value as with a date. I haven't figured out the details of the ranking system on Wikidata myself yet - I'm not sure whether you can have more than one "preferred rank" value or not. Thanks. [[User:Mike Peel|Mike Peel]] ([[User talk:Mike Peel|talk]]) 18:30, 28 January 2017 (UTC)
:::: {{reply to |Mike Peel|label=Mike}} As far as I know, you can have many of each rank as you wish. The question is how should we deal with the case where multiple values of the property exist with the same rank? We would want to return as a list multiple values of most fields, e.g. occupation, but surely we wouldn't want multiple dates of birth returned? --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 20:56, 28 January 2017 (UTC)
::::: Apparently sometimes multiple dates of birth do need to be returned, e.g. from [[:d:Q885424]]. So maybe just return all of the referenced statements for the highest rank available? Thanks. [[User:Mike Peel|Mike Peel]] ([[User talk:Mike Peel|talk]]) 22:52, 6 February 2017 (UTC)
:::::: I'd prefer to use a local parameter for such a case. We could then have "3 or 9 August 1858", rather than the list that the call would naturally return: "3 August 1858, 9 August 1858". That's because the call doesn't know that we would write the list of dates in the former way for disputed dates of birth. I could certainly make the list output with "or" separating the dates, but shorthand styles like "3 or 9 August 1858" and "30 July or 9 August 1858" are a lot more work to program, and hence more room for errors and edge cases, and I'd want to see a lot more testing in sandbox if we went down that route. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 04:34, 7 February 2017 (UTC)
 
== Unsafe use of labels ==
 
Code like this:
 
<source lang=Lua>
local label = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end
if sitelink then
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
</source>
 
or like this:
 
<source lang=Lua>
local label = mw.wikibase.label(valueID)
if not label then label = valueID end
if sitelink then
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
</source>
 
is not safe. Labels may contain any characters including [|]{} so a label could be constructed to generate e.g. any internal or external links. I suggest that you add [[mw:Extension:Scribunto/Lua_reference_manual#mw.text.nowiki|mw.text.nowiki]](label) before using labels in wikitext. The same applies to any string and text values from Wikidata. Best regards, [[User:Dipsacus fullonum|Dipsacus fullonum]] ([[User talk:Dipsacus fullonum|talk]]) 07:15, 3 February 2017 (UTC)
:
: That's interesting. As it is clearly necessary to apply the mw.text.nowiki() function to every call to mw.wikibase.label() (without exception for the reasons given), it makes you wonder why the nowiki function is not applied to the mw.wikibase.label() internally. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 20:23, 5 February 2017 (UTC)
 
== Alternative field names ==
 
{{Contains Chinese text}}
 
Hi, I'm from Chinese Wikipedia. How can I give an alternative name to a field? Because the Chinese language has multiple writing systems (traditional + simplified), each parameter usually both has a traditional and simplified (and sometimes, English) name. How to make the <code>fetchwikidata</code> or <code>suppressfields</code> field work when a traditional or simplified name of a parameter is filled in? Such as:
 
[[d:Q36970|Jackie Chan (Q36970)]]
<pre>
{{Infobox entertainer/WD
<!-- English Wikipedia does not have this template, but this template is available on Chinese Wikipedia. It is called {{藝人/WD}} -->
| fetchwikidata = 出生地点
| name = Jackie Chan
| type = Actor
}}
{{to-do|collapsed=yes}}
</pre>
{{archives|search=yes}}
 
{{User:MiszaBot/config
or
|archiveheader = {{talkarchivenav}}
 
|maxarchivesize = 75K
<pre>
|counter = 8
{{Infobox entertainer/WD
|minthreadsleft = 3
<!-- English Wikipedia does not have this template, but this template is available on Chinese Wikipedia. It is called {{藝人/WD}} -->
|minthreadstoarchive = 1
| fetchwikidata = 出生地點
|algo name = Jackie Chan = old(60d)
|archive type = ActorModule talk:WikidataIB/Archive %(counter)d
}}
</pre>
 
==Multiple qualifiers==
or
Is there a way to filter a property with many values by two or more qualifiers? [[User:Serresmap|Serresmap]] ([[User talk:Serresmap|talk]]) 00:18, 10 April 2024 (UTC)
 
<pre>
{{Infobox entertainer/WD
<!-- English Wikipedia does not have this template, but this template is available on Chinese Wikipedia. It is called {{藝人/WD}} -->
| fetchwikidata = birth_place
| name = Jackie Chan
| type = Actor
}}
</pre>
 
:@[[User:Serresmap|Serresmap]]: I don't think so. I recommend using [[Module:Wd]] instead, e.g. <code><nowiki>{{#invoke:wd|properties|Q55|P7295|P518=Q762943|P1365=Q11184}}</nowiki></code>. [[User:LennardHofmann|LennardHofmann]] ([[User talk:LennardHofmann|talk]]) 12:55, 12 April 2024 (UTC)
These will fetch place of birth from Wikidata. But now I can only use one of them to do that. --[[User:Dabao qian|Dabao qian]] ([[User talk:Dabao qian|talk]]) 16:24, 5 February 2017 (UTC)
:
: {{reply to |Dabao qian}} I'm not sure I understand all that happens on Chinese Wikipedia when multiple labels are available. Nevertheless, I'll try to explain as much of WikidataIB as I can. Both <code>fetchwikidata</code> and <code>suppressfields</code> work by looking for the label/name of the field that is passed in the invocation, within the string that is passed by the article to {{para|fetchwikidata}} and {{para|suppressfields}}. So if the template defines 'Birth place' as something like <code><nowiki>{{#invoke:WikidataIB |getValue |P19 </nowiki><b>|name=birth_place</b><nowiki> |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |noicon={{{noicon|}}} }}</nowiki></code>, then {{para|fetchwikidata|birth_place, birth_date, death_place, death_date}} (for example) would match the <code>"|name=birth_place"</code> in the infobox definition, and the call would return {{Q|P19}}. Using {{para|fetchwikidata|ALL}} in an article would return all properties that are invoked in the infobox definition.
: I think that you can avoid the multiple labels by deciding on using just one style of field name and documenting it, so that editors use just the string you specify in the list of fields passed to <code>fetchwikidata</code> and <code>suppressfields</code>. If you use <code>"|name=birth_place"</code> in the infobox definition, then editors have to use <code>"|fetchwikidata=abc, def, ..., birth_place, ..., xyz"</code>.
: I've just realised that your two examples you have 出生地點 ("Birth place") and 出生地点 (also "Birth place"). Does that mean you want to use ''both'' of those in your infoboxes? If so, then make two invocations in the infobox definition, one with <code>|name=出生地點</code> and the other with <code>|name=出生地点</code>. Then use {{para |fetchwikidata |abc, ..., 出生地點 出生地点, ..., xyz}} and both will be displayed, if that's what you want.
: Please ping me again if I've not answered your query with something useful, and let me know if I can be more specific. Cheers --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 19:32, 5 February 2017 (UTC)
 
==Option to get 'raw value'==
== getQualifierValue only works for properties that are Q-number valued ? ==
There should be an option to get '''raw value''' of a wikidata item using this module, similar to what we get from {{code|{{wikidata{{!}}property{{!}}raw{{!}}...}}}}.
 
Absence of this option makes the template difficult to be used in infoboxes which require some wikidata property of a wikidata item which in turn is specified by some property of the given {{para|qid}}.
It seems getQualifierValue only works for properties that are Q-number valued.
 
This is necessary in order to comply with [[Wikipedia:Wikidata/2018 Infobox RfC | this RFC]] and [[Wikipedia:Wikidata#Appropriate_usage_in_articles|this list of RFCs]] which make it mandatory to use {{tl|Wdib}} with {{para|osd|true}} in infoboxes.
Is there a good reason for this? I had been hoping to use it to extract a qualifier from a property that is external-identifier valued, for example:
 
An example requirement is {{para|mla}} of {{tl|Infobox Indian Constituency (wd)}}. [[User Talk:Riteze|<span style="color:green;">Riteze</span>]] 08:19, 4 March 2025 (UTC)
* {{#invoke:WikidataIB |getQualifierValue |P1367 |pval=simpson-charles-walter-18851971 |qual=P1114 |fetchwikidata=ALL |qid=Q5083334 }}
 
== open and close quotation mark ==
to extract the number of [https://artuk.org/discover/artists/simpson-charles-walter-18851971 works at Art UK] associated with [[Charles Walter Simpson (English artist)]] ({{Q|5083334}}).
 
Also,Many isof it[[Quotation possiblemark]]s tohave omitopening theand valueclosing, forso <code>pval=</code>both inopen casesand whereclose therequotation ismark onlyshould onebe pval, since my template is not currently writtenable to handlespecified casesin when there is more than one? Thanks[[Module:WikidataIB/titleformats|/titleformats]]. [[User:JhealdFlatLanguage|JhealdFlatLanguage]] ([[User talk:JhealdFlatLanguage|talk]]) 0918:3554, 2026 FebruaryMarch 20172025 (UTC)
:Please see [[MOS:CURLY]]. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 01:57, 27 March 2025 (UTC)
::/titleformats is for i18n, so projects other than enwiki should be considered. --[[User:FlatLanguage|FlatLanguage]] ([[User talk:FlatLanguage|talk]]) 01:59, 27 March 2025 (UTC)