Module talk:WikidataIB: Difference between revisions

Content deleted Content added
 
(49 intermediate revisions by 17 users not shown)
Line 1:
{{Permanently protected}}
{{WPBS|
{{WikiProject Wikidata}}
}}
{{banner holder|text=Page history|1=
{{oldtfdfull|date= 2020 September 15 |result=keep |disc=Module:Wikidata Infobox}}
}}
{{to-do|collapsed=yes}}
{{archives|search=yes}}
{{User:MiszaBot/config
|archiveheader = {{talkarchivenav}}
Line 10 ⟶ 17:
|archive = Module talk:WikidataIB/Archive %(counter)d
}}
{{oldtfdfull|date= 2020 September 15 |result=keep |disc=Module:Wikidata Infobox}}
{{archives|search=yes}}
 
== Possible bug fix ==
 
I'm trying to set up my own wiki, and I've been importing various templates and modules from Wikipedia. Something I imported eventually complained that this module was missing, so I imported it.
 
At this point I feel like I should note that I have no idea what this module is for. With that said:
 
After importing this module, pages that were using it then started complaining about an attempted dereference of a nil reference. I "fixed" it (on my local site), at least insofar as that those pages no longer complain, but I don't want to update the module here on Wikipedia because, like I said, I have no idea what it's for. So, in case someone more knowledgeable than me wants to check if it would be appropriate to add my change here too, what I did was insert this line at the top of function _getcommonslink:
 
<code>if not mw.wikibase then return nil end</code>
 
The mw.wikibase variable is dereferenced a couple lines later, which is where the error was thrown from. I hope this helps. -[[User:Rwv37|Rwv37]] ([[User talk:Rwv37|talk]]) 23:24, 9 February 2022 (UTC)
:mw.wikibase is the library of functions for accessing wikibase items via Lua. It's documented [https://doc.wikimedia.org/Wikibase/master/php/md_docs_topics_lua.html here]. Without that extension I cannot think how this module can do anything for you on your home wiki. &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 03:37, 24 February 2022 (UTC)
 
::Yeah, I eventually figured out what Wikibase is. The thing the module could do for my home wiki is exist, so as to stop other imported things from complaining about it being missing. Turns out that issues like this are all over the code, not just in Module:WikidataIB. -[[User:Rwv37|Rwv37]] ([[User talk:Rwv37|talk]]) 10:15, 5 March 2022 (UTC)
 
==How to get the latest value instead of the largest value?==
 
This gives the largest population value:
* <nowiki> {{population WD|Härnösand Municipality}} </nowiki>-> {{population WD|Härnösand Municipality}}
* <nowiki> {{#invoke:WikidataIB |getValue |P1082 |qid={{GetQID|Härnösand Municipality}} |fwd=ALL |rank=p n |osd=no |sorted=yes |list=p-1 |qual=ALL}} </nowiki>-> {{#invoke:WikidataIB |getValue |P1082 |qid={{GetQID|Härnösand Municipality}} |fwd=ALL |rank=p n |osd=no |sorted=yes |list=p-1 |qual=ALL}}
 
I want it to show the newest value, which is 21,012 <small>(2021)</small>. Is that possible using WikidataIB? Also in case all values have the same rank? [[User:Tomastvivlaren|Tomastvivlaren]] ([[User talk:Tomastvivlaren|talk]]) 09:41, 1 March 2022 (UTC)
 
:I don't think there is a function for that. You should set preferred value and then use rank=best &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 11:26, 1 March 2022 (UTC)
* <nowiki> {{#invoke:WikidataIB |getValue |P1082 |qid=Q209634|fwd=ALL |rank=best |osd=no |qual=ALL}} </nowiki>-> {{#invoke:WikidataIB |getValue |P1082 |qid=Q209634|fwd=ALL |rank=best |osd=no |qual=ALL}}
 
::Thnx for your good advise. I believe my current solution shows the most recently edited value (which often but not always is the newest value), if all values have the same rank:
::<nowiki>{{#invoke:WikidataIB |getValue |P1082 |qid=... |fwd=ALL |rank=best |osd=no |qual=ALL|list=p-1}}</nowiki>
::[[User:Tomastvivlaren|Tomastvivlaren]] ([[User talk:Tomastvivlaren|talk]]) 23:53, 10 March 2022 (UTC)
 
==Multiple qualifiers==
==How to only show year of a numeric value?==
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)
How can I only show the year of a numeric value, for example the year for the population size of a city? Now I used the following advanced string manipulation to remove the value, which makes the script slow - it gives the error message "The time allocated for running scripts has expired" if the script is included a large number of times in the same Wikipedia page:
*<code><nowiki>{{#invoke:Ustring|gsub|{{#invoke:WikidataIB |getValue |P1082 |qid=... |fwd=ALL |rank=best |osd=no |qual=P585|qdf=y|noicon=TRUE|list=p-1}}|^[%d,± ]* %((%d%d%d%d)%)|%1}}</nowiki></code>
 
:@[[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)
[[User:Tomastvivlaren|Tomastvivlaren]] ([[User talk:Tomastvivlaren|talk]]) 00:06, 11 March 2022 (UTC)
 
==Option to get 'raw value'==
== sorted=true: by what? ==
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}}.
I understand that {{para|sorted|true}} sorts the returned values, but I cannot see by what ordering. Eg, for {{Q|Q2079986}}, {{Property|P703}}:
::sorted=false: {{#invoke:WikidataIB |getValue |P703 |qid=Q2079986|fwd=ALL|sorted=false }} dflt
::sorted= true: {{#invoke:WikidataIB |getValue |P703 |qid=Q2079986|fwd=ALL|sorted=true }}
:So, true-results have unexpected order IMO. (Incidentally, the itempage has/shows alphabetical order).
[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 13:26, 26 September 2022 (UTC)
 
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.
:Does it have to do with wikilinked/unlinked? If so, by some rationale or because of code like "<nowiki>[[...</nowiki>"? [[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 13:28, 26 September 2022 (UTC)
::@[[User:DePiep|DePiep]] From the doc page/comments: {{tq|It's only a very dumb alphabetical sort and sorts linked values as "<nowiki>[[</nowiki> ..."}}. So a literal alphabetical sort that doesn't break up links to sort by label. That seems to match your example as well. -- [[User:Ferret|ferret]] ([[User_talk:Ferret|talk]]) 13:30, 26 September 2022 (UTC)
:::Thanks; makes me feel good having the question right ;-)
:::Consider answered. [[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 13:38, 26 September 2022 (UTC)
 
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)
== How to add references ==
 
== open and close quotation mark ==
Is there a way to show references? {{tl|wikidata}} has this nice option:
:<code><nowiki>{{wikidata|properties|linked|references|normal+|Q18216|P703}}</nowiki></code>
:&rarr; {{wikidata|properties|linked|references|normal+|Q18216|P703}}
But afaik it is less controllable. Some live examples in infoboxes? -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 14:48, 26 September 2022 (UTC)
{{reflist-talk}} [[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 14:48, 26 September 2022 (UTC)
 
Many of [[Quotation mark]]s have opening and closing, so both open and close quotation mark should be able to specified in [[Module:WikidataIB/titleformats|/titleformats]]. [[User:FlatLanguage|FlatLanguage]] ([[User talk:FlatLanguage|talk]]) 18:54, 26 March 2025 (UTC)
:As far as I know, this module was never designed to produce references. It would be nice to produce well formatted references. I think it will be quite challenging to match an existing citation style on an article. &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 15:11, 26 September 2022 (UTC)
::Ouch.Please Thissee hurts..[[MOS:CURLY]]. Thx. [[User:DePiepJonesey95|DePiepJonesey95]] ([[User talk:DePiepJonesey95|talk]]) 1801:57, 2627 SeptemberMarch 20222025 (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)