Module talk:WikidataIB/Archive 7: Difference between revisions

Content deleted Content added
m Archiving 1 discussion(s) from Module talk:WikidataIB) (bot
m Archiving 1 discussion(s) from Module talk:WikidataIB) (bot
Line 263:
::: I think the solution to the locally supplied image is to wrap the wikidata call for the caption in something like <code><nowiki>{{#if:{{{image|}}} |{{caption|}} |{{wdib |fwd=ALL |osd=n |P18 |qual=P2096 |qualsonly=y |qid={{{qid|}}} }}</nowiki></code> which would only use a locally supplied caption with a locally supplied image.
::: There's a constraint on Wikidata that {{q|P18}} should have a single-value, but it does get ignored. You should always limit the number of images returned by setting {{para|maxvals|1}} if you're using the usual image syntax. That will return the first image and the first media legend, so it should avoid the potential for having a caption not associated with the image (probably!). --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 20:40, 30 September 2020 (UTC)
 
== Help! ==
 
There are a problem, I can't work it out. Maybe I need <code>getPropOfProp</code>, or perhaps <code>getQualifierValue</code> or <code>getValueByQual</code> or even <code>getSumOfParts</code>. The trouble there is that doesn't seem to be much in the way of documentation.
 
The problems is of a (Philippine) place, say {{Q|Q13786}} with property {{Q|P610}} with one or more instances of places as qualifier, for instance {{Q|Q6922008}} which will each have a qualifier of {{Q|P2044}}. So how can I show direct elevation? → Cebu 1097 m
 
[[User:Not Samuel Pepys|Not Samuel Pepys]] ([[User talk:Not Samuel Pepys|talk]]) 14:16, 23 October 2020 (UTC)
:
: {{re|Not Samuel Pepys}} For {{q|Q13786}} with property {{q|P610}}, you can find the value of the qualifier {{q|P2044}} like this:
:* <code><nowiki>{{#invoke:WikidataIB |getValue |P610 |fwd=ALL |osd=n |noicon=t |qual=P2044 |qid=Q13786}}</nowiki></code> → {{#invoke:WikidataIB |getValue |P610 |fwd=ALL |osd=n |noicon=t |qual=P2044 |qid=Q13786}}
: If you just want the value of of the qualifier without the property value, then add the {{para|qualsonly|true}} parameter:
:* <code><nowiki>{{#invoke:WikidataIB |getValue |P610 |fwd=ALL |osd=n |noicon=t |qual=P2044 |qualsonly=t |qid=Q13786}}</nowiki></code> → {{#invoke:WikidataIB |getValue |P610 |fwd=ALL |osd=n |noicon=t |qual=P2044 |qualsonly=t |qid=Q13786}}
: If you want the unit abbreviated or conversions, let me know as that will require a small patch to enable abbreviations and conversions for qualifiers using getValue.
: Optionally, you can fetch the values of properties of {{q|Q6922008}} by using getPropOfProp from {{q|Q13786}} like this:
:* <code><nowiki>{{#invoke:WikidataIB |getPropOfProp |prop1=P610 |fwd=ALL |osd=n |noicon=t |prop2=P2044 |qid=Q13786}}</nowiki></code> → {{#invoke:WikidataIB |getPropOfProp |prop1=P610 |fwd=ALL |osd=n |noicon=t |prop2=P2044 |qid=Q13786}}
: That works because {{q|P610}} is stored in Wikidata both as a qualifier in the {{q|Q13786}} entry ''and'' as a property in the {{q|Q6922008}} entry.
: Unit abbreviations and conversions already work for getPropOfProp:
:* <code><nowiki>{{#invoke:WikidataIB |getPropOfProp |prop1=P610 |fwd=ALL |osd=n |noicon=t |prop2=P2044 |uabbr=t |qid=Q13786}}</nowiki></code> → {{#invoke:WikidataIB |getPropOfProp |prop1=P610 |fwd=ALL |osd=n |noicon=t |prop2=P2044 |uabbr=t |qid=Q13786}}
:* <code><nowiki>{{#invoke:WikidataIB |getPropOfProp |prop1=P610 |fwd=ALL |osd=n |noicon=t |prop2=P2044 |conv=y |qid=Q13786}}</nowiki></code> → {{#invoke:WikidataIB |getPropOfProp |prop1=P610 |fwd=ALL |osd=n |noicon=t |prop2=P2044 |conv=y |qid=Q13786}}