Module talk:WikidataIB
![]() | Module:WikidataIB is permanently protected from editing because it is a heavily used or highly visible module. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify an administrator or template editor to make the requested edit.
|
|
![]() | This module was considered for deletion on 2020 September 15. The result of the discussion was "keep". |
|
||||||||
This page has archives. Sections older than 60 days may be auto-archived by Lowercase sigmabot III if there are more than 3. |
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:
if not mw.wikibase then return nil end
The mw.wikibase variable is dereferenced a couple lines later, which is where the error was thrown from. I hope this helps. -Rwv37 (talk) 23:24, 9 February 2022 (UTC)
- mw.wikibase is the library of functions for accessing wikibase items via Lua. It's documented here. Without that extension I cannot think how this module can do anything for you on your home wiki. — Martin (MSGJ · talk) 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. -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:
- {{population WD|Härnösand Municipality}} -> 24,502 (2025)
- {{#invoke:WikidataIB |getValue |P1082 |qid={{GetQID|Härnösand Municipality}} |fwd=ALL |rank=p n |osd=no |sorted=yes |list=p-1 |qual=ALL}} -> 25,325 (2017)
I want it to show the newest value, which is 21,012 (2021). Is that possible using WikidataIB? Also in case all values have the same rank? 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 — Martin (MSGJ · talk) 11:26, 1 March 2022 (UTC)
- {{#invoke:WikidataIB |getValue |P1082 |qid=Q209634|fwd=ALL |rank=best |osd=no |qual=ALL}} -> 24,502 (2025)
- 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:
- {{#invoke:WikidataIB |getValue |P1082 |qid=... |fwd=ALL |rank=best |osd=no |qual=ALL|list=p-1}}
- Tomastvivlaren (talk) 23:53, 10 March 2022 (UTC)
How to only show year of a numeric value?
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:
{{#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}}
sorted=true: by what?
I understand that |sorted=true
sorts the returned values, but I cannot see by what ordering. Eg, for quassin (Q2079986), found in taxon (P703):
- sorted=false: Picrasma crenata, Picrasma javanica, Picrasma quassioides, Quassia africana, Quassia amara, Samadera indica dflt
- sorted= true: Quassia africana, Picrasma crenata, Picrasma javanica, Picrasma quassioides, Quassia amara, Samadera indica
- So, true-results have unexpected order IMO. (Incidentally, the itempage has/shows alphabetical order).
DePiep (talk) 13:26, 26 September 2022 (UTC)
- Does it have to do with wikilinked/unlinked? If so, by some rationale or because of code like "[[..."? DePiep (talk) 13:28, 26 September 2022 (UTC)
- @DePiep From the doc page/comments:
It's only a very dumb alphabetical sort and sorts linked values as "[[ ..."
. So a literal alphabetical sort that doesn't break up links to sort by label. That seems to match your example as well. -- ferret (talk) 13:30, 26 September 2022 (UTC)- Thanks; makes me feel good having the question right ;-)
- Consider answered. DePiep (talk) 13:38, 26 September 2022 (UTC)
- @DePiep From the doc page/comments:
How to add references
Is there a way to show references? {{wikidata}} has this nice option:
But afaik it is less controllable. Some live examples in infoboxes? -DePiep (talk) 14:48, 26 September 2022 (UTC)
References
- ^ L A Mitscher; Y H Park; D Clark; J L Beal (March 1980). "Antimicrobial agents from higher plants. Antimicrobial isoflavanoids and related substances from Glycyrrhiza glabra L. var. typica". Journal of Natural Products. 43 (2): 259–269. doi:10.1021/NP50008A004. ISSN 0163-3864. PMID 7381508. Wikidata Q71214999.
DePiep (talk) 14:48, 26 September 2022 (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. — Martin (MSGJ · talk) 15:11, 26 September 2022 (UTC)