Module talk:Wd

(Redirected from Template talk:Wikidata)
Latest comment: 8 days ago by Janhrach in topic 2 urls in source
WikiProject iconWikidata
WikiProject iconThis module is within the scope of WikiProject Wikidata, a collaborative effort to improve Wikipedia's integration with Wikidata.
If you would like to participate, please visit the project page.

Current population value

edit

Wikidata:Q6045892 page contains population values between 2007-2022. However, when I type the wikidata:Property:P1082 value, the template calls the population value for 2007. What should I do to have it call up the population value for the most recent year?

{{wd|property|Q6045892|P1082}} → 2,010

Thank you. Sadrettin (talk) 10:48, 7 April 2024 (UTC)Reply

You have at least two options, @Sadrettin:
  • {{wd|property|Q6045892|P1082|P585=2022}} >> 3,783
  • Change the rank of the latest property on wikidata to preferred
Ponor (talk) 13:08, 7 April 2024 (UTC)Reply
{{#invoke:wd
	|property
	|P1082
	|P585={{#invoke:Wikidata
		|getRawQualifier
		|qualifier=P585
		|property=P1082
		|sort=P585
		|invert=true
		|limit=1
	}}
}}
The above filters the multiple values of population (P1082 property) by the latest year (P585 qualifiers). If you add |P459=Q6042918 after |P1082, then the result is also filtered by determination method. Serresmap (talk) 18:55, 18 April 2024 (UTC)Reply
@Serresmap: Thank you for your reply. When I wrote this code exactly, it didn't work. Could there be a problem? Could you please check again? --Sadrettin (talk) 08:41, 23 April 2024 (UTC)Reply

Getting Template:Update tracker working with qualifiers

edit

I've been working on developing {{Update tracker}} and its child {{Update tracker item}}, templates for articles that use {{Wikidata}} that create a table for the talk page that lists which information needs to be updated (convenient for subjects like colleges that have a lot of data that needs updating every year).

I've gotten it mostly functional, except that I can't figure out how to get it to work with qualifiers (see the testcases). To function, it needs to call extra qualifier commands only when the |qualifier= or |qualifier-value= parameters are defined. I don't know of a way to conditionally add extra parameters, though, and keeping them blank causes an error.

Does that make sense? Anyone able to help? Sdkbtalk 14:05, 10 April 2024 (UTC)Reply


@Sdkb: what do you mean by "there's an error" (in your testcases)? Is it an error thrown by the module or is it just the wrong data that you're getting? I suppose you tried
{{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} |{{{qualifier|}}}={{{qualifier-value|}}} }}
Did you leave out the vertical bars in the last two variables? I did a quick test in your code, previewing your test cases while editing, and the previous code did return some values and no obvious errors.
I see another problem here / for Scripps College (Q10664609). This:
  • {{Wikidata|qualifier|single|eid=Q10664609|P1128|P585|P518=Q5428874}}→ 2019 (current WD value is 2019)
seems alright. However, in
  • {{Wikidata|qualifier|single|eid=Q10664609|P1128|P585}} → 2019
you'd expect the result to be 2020 (right?), but without any qualifiers the call returns the first of the two values of:
  • {{Wikidata|qualifier|eid=Q10664609|P1128|P585}} → 2019; September 2020
This would require a change on WD, another "applies to" or "rank: preferred", I believe.
Although, this does seem to work, so |qualifier= should be given with no value when there are other nonempty qualifiers for the property:
  • {{Wikidata|qualifier|single|eid=Q10664609|P1128|P585|P518=}}→ September 2020
Ponor (talk) 12:56, 10 April 2024 (UTC)Reply
Thanks for the reply, Ponyo! The error I'm referencing came from the fact that |qualifier= and |qualifier-value= are optional, and the most simple use case (the first two test cases) leave them out. The previous code I tried removed the equal sign if they were not present, causing the template to evaluate as
{{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} | }}
, where the pipe and blank parameter at the end causes it to become blank. Curiously, using your more basic method, the template evaluates as
{{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} | = }}
, which I didn't even try because I presumed it would produce even more of an error, but it actually seems to cause it to work as intended. So that resolves my problem, although I don't trust that blank equals signs will always be okay for {{Wikidata}} as it evolves in the future, so if there's a more durable solution that'd be good to know about. Sdkbtalk 19:45, 10 April 2024 (UTC)Reply
@Sdkb: glad it worked (wasnt' sure what exactly wasn't working). I don't think the blank equals sign will cause any problems; when there's nothing on its left, it should be discarded. If, however, you want to run some tests on your variables, you can try
{{#if:{{{qualifier|}}}| {{Wikidata||{{{qualifier}}}={{{qualifier-value}}}}} | {{Wikidata|}} }}
Someone more familiar with parsers and stuff might tell us if there's a better way; something tells me there has to be a hard-coded = sign, and not its replacements. Ponor (talk) 20:23, 10 April 2024 (UTC)Reply
The same test, using the nothing-on-the-left-of-equals-sign trick:
{{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} |{{#if: some function of {{{qualifier|}}} and {{{qualifier-value}}} | {{{qualifier}}} | }} = {{{qualifier-value}}} }}
Ponor (talk) 20:30, 10 April 2024 (UTC)Reply

Reference without title

edit

If a reference doesn't have a title, the URL isn't shown and "Error: Unable to display the reference properly. See the documentation for details." is shown instead.
Would it be possible to not use {{Cite web}} if there's no title so that the URL is shown? The RedBurn (ϕ) 15:59, 11 May 2024 (UTC)Reply

This is an as-yet unaddressed problem with the module. See above. – Jonesey95 (talk) 03:47, 13 May 2024 (UTC)Reply
I plan to improve this error message; in the next ~3 months, if nothing wrong. But I agree with you it would probably be better if we let {{Cite web}} to report missing titles. I thinks so because if the reference rendering fails, the module will need to report two errors (one for {{Cite web}} missing/unknown param on Wikidata, and one error for {{Cite Q}}) – this would be probably too confusing for non-technical editors.
Is anybody opposed to this change?
Janhrach (talk) 09:35, 25 May 2024 (UTC)Reply
I have made the said change to the sandbox. Here is a result sample:
[1]
Original behavior, for comparison:
[1]
Janhrach (talk) 17:32, 7 June 2024 (UTC)Reply

References

  1. ^ a b . Federal Statistical Office https://www.pxweb.bfs.admin.ch/pxweb/de/. Retrieved 15 June 2020. {{cite web}}: Missing or empty |title= (help)
@The RedBurn: Oops, I misread to not use {{Cite web}} in your comment as "to use {{Cite web}}". As for this, we could probably not; see this discussion. To quote an editor from the discussion: Titles are required so when {{cite web}} emits a missing title error, that is a good thing, because someone can go to wikidata and fix it.
As for the change I did (even though it's not what you proposed), what do you think of it?
Janhrach (talk) 06:40, 9 June 2024 (UTC)Reply
Your change is great, I actually thought {{Cite web}} was the culprit for hiding the URL when there's no title. The RedBurn (ϕ) 06:29, 10 June 2024 (UTC)Reply
Ok, I went ahead and updated the module. Janhrach (talk) 19:18, 10 June 2024 (UTC)Reply
@Janhrach: This is a huge improvement, thank you! Polygnotus (talk) 19:42, 15 June 2024 (UTC)Reply

imported from Wikimedia project (P143) and Wikimedia import URL (P4656) in references

edit

I propose to modify the module to ignore references containing these properties. This seems to be the correct way of handling them – these references should not contain any information useful for Wikipedia references. Any thoughts? Janhrach (talk) 15:17, 15 June 2024 (UTC)Reply

@Janhrach, Agree. Non Wiki references are only proper references. Arjunaraoc (talk) 11:13, 21 June 2024 (UTC)Reply
I have made the change to the sandbox. References containing inferred from (P3452) are also fully ignored. Janhrach (talk) 16:41, 21 June 2024 (UTC)Reply
  Done: module updated. Janhrach (talk) 09:49, 23 June 2024 (UTC)Reply

Wikipedia article link in plain form needed

edit

While creating a variant template for use on Andhra Pradesh Village articles which uses{{ Infobox settlement}}, I needed wikipedia site link text in plain form so that I can change the visible text to remove suffixes in label names like district or mandal. I am unable to do that, as the current linked form gives a full fledged link with site link text and label as its visible text. I am unable to process such text as the response has pipe symbol in it. Is there any other way to get only Wikipedia article link text in plain form? Arjunaraoc (talk) 11:18, 21 June 2024 (UTC)Reply

I think this module could not output sitelinks (i.e. interwiki links hosted in Wikidata), linked or not. Could you clarify what exact arguments are you giving to the template call? Janhrach (talk) 13:08, 21 June 2024 (UTC)Reply
Template:Sitelink or parts of its code? Ponor (talk) 13:42, 21 June 2024 (UTC)Reply
@Ponor, Thanks for your help. It worked. I used the corresponding function from {{WikidataIB}} in my code. @Janhrach, Your response is correct. I wanted the sitelink in plain text form for the same language, instead of link form with label. Arjunaraoc (talk) 00:57, 22 June 2024 (UTC)Reply

2 urls in source

edit

There are 2 URLs in the source of the 2023 population data on this page: reference URL However, one of them appears on Wikipedia. Is it possible for 2 URLs to appear? Sadrettin (talk) 10:21, 24 June 2024 (UTC)Reply

No, it is not possible for a Wikipedia reference to have two URLs. I am not sure if the Wikidata reference you mentioned is valid; it is possible the reference should be split into two (the first reference would contain the first URL, and the second reference would contain the second URL) even if the other metadata are the same. Janhrach (talk) 07:36, 29 June 2024 (UTC)Reply