Module talk:Wd
| Module:Wd is permanently protected from editing as 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 is the talk page for discussing improvements to the Wd module. |
|
| Archives: 1Auto-archiving period: 3 months |
| This module does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||
| ||||||||
| Use Wikipedia talk:Wikidata for general Wikidata support discussions. |
| Related pages |
|---|
| Text and/or other creative content from this version of Module:Wd was copied or moved into Module:European and national party data/Wd with this edit on 22 May 2025. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted as long as the latter page exists. |
Specifying URL alive/dead status
[edit]Citations with archive URLs are displayed differently when the URL is specified as alive via |url-status=live vs. when it's specified as dead or not specified (see first paragraph of here). Would it be possible to create a way for this template to likewise specify URL status? Sdkb talk 00:22, 29 July 2025 (UTC)
- Yes, maybe sometime in the future, but it is not supported right now. Janhrach (talk) 16:20, 7 August 2025 (UTC)
Handling of Wikidata refs - empty titles and missing properties
[edit]We have a problem on cywiki where we have pages taking references from Wikidata. In 2023, @Janhrach very kindly forked the code and applied some additional handling to prevent visible errors. Time moves on and the code in the module has been refactored. I applied this version but it shows errors again - see https://cy.wikipedia.org/wiki/8_Mile
I would like to keep the module up-to-date, so I had various attempts to re-apply the previous fix - but as variables have changed, it's quite tricky. There are also some more significant errors regarding those properties such as Rotten Tomatoes and Meta Critic, which is potentially easier to fix. Is there a possibility of handling this in an easier way? I would prefer not to put in special handling just for us as it limits future updates, but it would be good to know what's feasible. I could revert my changes to what was working, but I suspect that I would also need to revert other updates to Citation/CS1 modules as well. Thank you. Dafyddt (talk) 22:42, 22 August 2025 (UTC)
- Regarding the specific errors you have mentioned, the problem was that Wikidata says that references citing online databases need to contain both stated in (P248) and a property of the External identifier data type, while the references causing errors contained only the latter. This may seem like a minor technicality, but database references are handled by an ugly hack in the module, and I do not want to make this hacky code more complicated to support references like this. I plan to fix this issue by creating a separate template for citing database references; this will hopefully also eliminate cryptic error messages like these.
- As for re-introducing the cywiki fix, the old code is probably of little use, because the code has changed quite a lot. If it is really needed, I can try to reimplement it, but I would strongly prefer if you waited until I make the fix I have mentioned in the previous paragraph.
- Also, regarding the changes to this module since I made the cywiki fix, there were two of them that are especially relevant here:
- I added verbose error messages. They should mostly be comprehensible after reading the documentation. I agree though that the errors you have mentioned are hard to understand; I will fix that.
- |title= is no longer a mandatory param for {{Cite web}}. In practice, this means that missing titles in references do not cause errors in this module, but in the citation template, like you see in the article you have linked. This hopefully made the errors more understandable. When I create the database-citation template, many of these missing-title errors could be eliminated.
- —Janhrach (talk) 14:19, 26 August 2025 (UTC)
|title= is no longer a mandatory param for {{Cite web}}.
False. I don't know where you got that idea but you are mistook.|title=is, and likely will always be, required by{{cite web}}. If you have found some place where it is stated that|title=is not required, name that place so that it can be visited and fixed.- —Trappist the monk (talk) 14:40, 26 August 2025 (UTC)
- I meant that this module does not consider it mandatory. I wrote that
this means that missing titles in references do not cause errors in this module, but in the citation template[...]
Janhrach (talk) 14:43, 26 August 2025 (UTC)- Yes, I saw that, but your initial declaration that
|title=is not required by{{cite web}}is false. That declaration cannot be allowed to stand unchallenged. - —Trappist the monk (talk) 14:52, 26 August 2025 (UTC)
- I should have made it clear that I refered to my changes to this module. I now see that
changes since I made the cywiki fix
could have been interpreted as including changes to CS1. Janhrach (talk) 14:59, 26 August 2025 (UTC)
- I should have made it clear that I refered to my changes to this module. I now see that
- Yes, I saw that, but your initial declaration that
- I meant that this module does not consider it mandatory. I wrote that
- Thanks for the reply! I will wait until your changes are made and may look at reverting our copy of Wd until that's done. Dafyddt (talk) 18:20, 26 August 2025 (UTC)
Language label
[edit]Hello, could we have more customization on Language label? I mean the part when code constructs cite web etc. I see it uses aliasesP.language which means for Q1860 it picks "English". Maybe we could "tell" in i18n configuration to return value of ISO 639-1 or even P424 if that language has it, of course we always fallback to aliasesP.language. This issue comes from my local wiki, for example Module is returning label in cite web that is giving CS1 error unrecognized language. Zygimantus (talk) 13:00, 28 August 2025 (UTC)
- Possible? Certainly. But there other, possibly more important issues to fix first, and I do not want to devote too much time to this module. (Its creator has seemingly abandoned it.) A temporary solution would be to map aliasesP.language to an empty parameter, which would cause the aliasesP.language to be ignored. Janhrach (talk) 15:01, 5 September 2025 (UTC)
- Yeah, need to think about it. I am generally using practice for modules from enwiki like this: I treat them like upstream repo and I do not want to "fork more" than adding translations or other minor localizations. Code changes in local wiki will mean that we would deviate too much from original code and could cause many problems. Zygimantus (talk) 10:19, 10 September 2025 (UTC)
- Yes, but the temporary workaround I proposed would imply modifying Module:wd/i18n (which is expected to be modified on other wikis), not the main module. Also, thinking about this issue, I may look into it sooner than I originally planned, because the solution I have in mind could also fix other problem, if it works. But I am quite busy these days, so don't expect anything for at least a month. Janhrach (talk) 19:53, 17 September 2025 (UTC)
- Yeah, need to think about it. I am generally using practice for modules from enwiki like this: I treat them like upstream repo and I do not want to "fork more" than adding translations or other minor localizations. Code changes in local wiki will mean that we would deviate too much from original code and could cause many problems. Zygimantus (talk) 10:19, 10 September 2025 (UTC)
Citation wrapper templates
[edit]The getReference method is quite cluttered and complicated. Fixing the |language= issue reported above would exacerbate this problem. One solution would be to create separate wrapper templates/submodules, one for Cite web and one for Cite Q, that would take QIDs as params, and generate Cite web/Cite Q calls with the QIDs converted to the form required by the citation templates. I think separating this functionality into wrappers would result in less clutter in the getReference function. Namely, this functionality would be moved into the wrapper templates:
- special handling for the first, unnamed param of Cite Q, which always needs to be given as a QID
- special handling of external-id properties, which are used (in some situations) to generate |url= for Cite web (This would enable removing the all the additionalProcessedProperties-related code cruft.)
- special handling of |language= in Cite web
- the methods getReferenceDetail and getReferenceDetails
- (possibly) special handling of numbered parameters, like |author= of Cite web.
One downside is that editors who copy this module to other wikis would need to notice the new wrapper templates/submodules, and adjust their /i18n. Failure to do the latter will not result in explicit error messages, but in weird references that contain QIDs instead of the wanted params.
Another downside would be that that the option of creating references that do not contain wikilinks would need to be removed. But I can't think why would anybody need this.
But speaking of other wikis, this change would have an advantage of letting their editors tweak the wrappers without worrying about the need of porting changes to new versions of the main module.
What do you think? Pinging Zygimantus.
—Janhrach (talk) 17:31, 18 September 2025 (UTC)
- I am ok whatever decision is, logical to have configurable on i18n side, maybe refactor how much possible, so Wd has only fetching logic but what to fetch and what to show should be controlled in a smart way using i18n. Zygimantus (talk) 13:49, 19 September 2025 (UTC)
- I too would like to see special handling of external-id properties but going further, if a wikimedia template is given for a reference source using an external-id, WD should use that citation template instead of {{cite web}} with the assumption that the wikimedia template is based on cite web and thus is typically setting parameters such as the identifier and URL. e.g. {{cite cgndb}} and {{cite bivouac}}. This would also fix the issues where WD is not retrieving the publisher and author. RedWolf (talk) 20:02, 25 October 2025 (UTC)
Property value with multiple references
[edit]If a WD property value has multiple references and you enclose the returned template value in <ref></ref> you end up with just one reference rather than multiple. For example, the elevation property value for Mount Robson (Q1161258) has two references but it ends up showing as a single reference but with both sources given in the one reference which is not ideal and technically incorrect as they should be displayed as separate references.
i.e.
The elevation of [[Mount Robson]] is {{Wikidata|property|raw|Q1161258|P2044}} metres.<ref>{{Wikidata|references|raw|Q1161258|P2044}}</ref>
The elevation of Mount Robson is 3954 metres.[1]
- ^ "Mount Robson". Bivouac Mountain Encyclopedia. Retrieved 20 October 2025. "Topographic map of Mount Robson". OpenTopoMap. Retrieved 20 January 2025.
Do I have to write a module that takes the output from {{Wikidata}} and wrap each citation with separate <ref></ref> or is there a template parameter that will do this for me? RedWolf (talk) 01:11, 22 October 2025 (UTC)
- Two examples:
{{Wikidata|references|raw|Q1161258|P2044}}- "Mount Robson". Bivouac Mountain Encyclopedia. Retrieved 20 October 2025. "Topographic map of Mount Robson". OpenTopoMap. Retrieved 20 January 2025.
{{Wikidata|references|Q1161258|P2044}}
- I am not sure if I understand you correctly, but I think that the latter example is what you want. In that case, you shouldn't use the raw argument.
References
- ^ "Mount Robson". Bivouac Mountain Encyclopedia. Retrieved 20 October 2025.
- ^ "Topographic map of Mount Robson". OpenTopoMap. Retrieved 20 January 2025.
- —Janhrach (talk) 15:12, 23 October 2025 (UTC)
- Yea I tried w/o the "raw" but then the references didn't show up properly in the References section. That problem seems to have been caused by wrapping the template output with <ref></ref>. The documentation is not clear that it wraps each citation template it generates with <ref></ref>. Thanks for the help. RedWolf (talk) 05:40, 25 October 2025 (UTC)
- I have clarified the documentation. Janhrach (talk) 17:56, 9 November 2025 (UTC)
- Yea I tried w/o the "raw" but then the references didn't show up properly in the References section. That problem seems to have been caused by wrapping the template output with <ref></ref>. The documentation is not clear that it wraps each citation template it generates with <ref></ref>. Thanks for the help. RedWolf (talk) 05:40, 25 October 2025 (UTC)