Extension talk:TemplateData

About this board

TemplateData editor and paramOrder

3
Summary by Thiemo Kreuz (WMDE)

Fixed in more recent versions.

MLRodrigue (talkcontribs)

I have a template that I created in MW 1.31 (TemplateData 0.1.2). The TemplateData editor does not create the paramOrder object, but the order still works, because it adheres to the order in which the parameters are defined in the source code.

However, in my MW 1.35 this no longer works. The params are ordered based on their name instead. Since the editor does not create the paramOrder, I now have to manually add it in the source code for each template. I would like to avoid that and don't know if it's just an issue in my wiki that the paramOrder object is not created automatically by the editor?

Thiemo Kreuz (WMDE) (talkcontribs)

I wasn't involved back then and can't tell when this broke, and where. It's potentially related to an unrelated change in Parsoid. But I'm aware of this issue. We fixed it just recently via gerrit:700350. This is part of MediaWiki 1.37, but not earlier, unfortunately. I think the best option you have (other than using 1.37) is to add a specific paramOrder to each template. The TemplateData editor isn't designed to do this automatically.

MLRodrigue (talkcontribs)

Okay, then I know what to do. Thanks for the prompt answer!

Pull values from the TemplateData block?

2
Summary by Thiemo Kreuz (WMDE)

Unclear request, suggest to use the API.

BCreegan (talkcontribs)

I would like to create a DPL that lists all the templates in a category, along with the description listed inside their data block. Is this possible?

Thiemo Kreuz (WMDE) (talkcontribs)

TemplateData not working in Nepali Wiki

6
Summary by Thiemo Kreuz (WMDE)

Works again.

बडा काजी (talkcontribs)

We recently change document subpage from "/doc" to "/कागजात"; now the TemplateData seems to be not working anymore. In other wiki it seems to work but not in Newiki.

Thiemo Kreuz (WMDE) (talkcontribs)

I'm afraid there is a lot of information missing. What changed? What doesn't work? Do you have an example link? One thing I can see is that ne:MediaWiki:Templatedata-doc-subpage still says "doc".

Whatamidoing (WMF) (talkcontribs)

Is this still broken?

Whatamidoing (WMF) (talkcontribs)

DannyS712, is this a problem that gets fixed by a config change?

बडा काजी (talkcontribs)

It seems to be working now

DannyS712 (talkcontribs)

No idea, sorry

Summary by Thiemo Kreuz (WMDE)

Works but makes it impossible to use the editor.

Meowcatx (talkcontribs)

The doc says:

"Note that  you cannot use {{#tag:templatedata}} in lieu of <templatedata>."

Why not? Works just fine for me, and was also the solution for a problem below.

(Topic:Wlc9a95pueut4dd6)

Thiemo Kreuz (WMDE) (talkcontribs)

$wgExtraNamespaces breaks the button?

4
Summary by Celyn Kendrick

It seems to be ok if I put the custom namespaces at the bottom of the LocalSettings.php. Maybe an order/race thing.

Celyn Kendrick (talkcontribs)

I've added a custom namespace, and the $wgExtraNamespaces[NS_FOO] = "Foo"; line in LocalSettings.php seems to break it so that the "Manage Template" button and "Information about Template Data" at the top of the editor pages don't show up. I've tried commenting out different additions to the LocalSettings.php to see what breaks it, and it's definitely localized to these two lines (Namespace and Talk Namespace).

Advice?

Thiemo Kreuz (WMDE) (talkcontribs)

I had a look at the code but unfortunately don't have an advice. The button appears exclusively in the Template namespace. Namespaces settings shouldn't affect it. Do you see error messages in the browser's JavaScript console?

Celyn Kendrick (talkcontribs)

[ZAoPZeU7uGrffEJTmVYQEwAAAYI] 2023-03-09 16:55:02: Fatal exception of type "InvalidArgumentException" (anonymous) @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=monobook:4

Tested it, and it only appears when I've got extra namespaces uncommented.

Celyn Kendrick (talkcontribs)

It seems to be ok if I put the custom namespaces at the bottom of the LocalSettings.php. Maybe an order/race thing.

How to enable wikitext within descriptions?

2
Push-f (talkcontribs)

I find the limitation that all descriptions must be plain text to be incredibly limiting. I often want to link related articles in descriptions.


Apparently the German Wikipedia has figured out a way to have the descriptions rendered as wikitext ... I'd like to know how to do the same.

Tacsipacsi (talkcontribs)

No, German Wikipedia figured out a way to have descriptions rendered as wikitext on the template documentation page – the actual TemplateData (used by VisualEditor etc.) still can’t contain links. See de:Vorlage:TemplateData#Verbesserte Präsentation for how the template documentation page and the actual TemplateData differ.

Reply to "How to enable wikitext within descriptions?"

TemplateData Editor suggested values input field not showing

7
MrSmith35 (talkcontribs)

So I've been learning to make templates over the last week or so, manually at first then I started to read about the TemplateData Editor and the possibility of adding a limited range of suggested parameter values by way of the suggested values field. However it just will not show whether I use the editor on an existing template or a new one from scratch. I'm running a recently updated MW 1.37.2 (previously 1.35) with extension versions that came with it, PHP 7.4.28, TemplateData Extension 0.1.2. Tried changing the skin, I normally use Citizen (1.17.4) but tried it with the vanilla, as installed, Vector 1.0.0, still no joy. I have updated the TemplateData Extension to 0.1.2 (3e7e798) 06:04, 1 June 2022. But alas nothing. Tried it with the 2010 wikitext editor, still nothing. I went onto Wikipedia and tried their TemplateData Editor which worked as advertised, so I know what to expect. I did find something on Phabricator about a bug with the suggested values filed which was reported April 2021, but that was different.

At my wits end - any suggestions?

Thanks

Thiemo Kreuz (WMDE) (talkcontribs)

At the moment the suggested values feature is still opt-in. This will change in the near future. Until then you need to add $wgTemplateDataSuggestedValuesEditor = true; $wgVisualEditorTransclusionDialogSuggestedValues = true; to your LocalSettings.php. I hope that helps.

MrSmith35 (talkcontribs)

Thanks for your quick reply Thiemo, much appreciated, worked a treat.

The suggested parameter values list appears as expected and I can edit existing lists. The drop down menu also works correctly in the insert template dialogue.

I have one minor issue, the insert Template dialogue works well except in my named User namespace. The dialogue appears and goes through the motions of doing what it's supposed to but after I hit apply no template is added to the article, but no error dialogue or warning appear. Though this is not that serious as I generally will be using templates in the Main namespace, is there a separate setting that I need to toggle to enable the dialogue in my User namespace?

Thiemo Kreuz (WMDE) (talkcontribs)

Oh, that sounds like a bug. Unfortunately I can't reproduce it on my machine. Can you provide more information and maybe report it?

MrSmith35 (talkcontribs)

Hi,

Yes I could, what do you need to know, please keep in mind I am a complete novice wrt MediaWiki and stuff like php. I can just about follow along with good instructions otherwise I get lost pretty quickly. Are there are specific logs I could easily find that might help, I couldn't see anything in the public logs on the wiki. My set up is on a Synology NAS - a custom install of MediaWiki as I couldn't get the Synology supported app working. I run it on Apache 2.4 with PHP 7.4 and MariaDB 10.

Thiemo Kreuz (WMDE) (talkcontribs)

Does something appear in your browser's JavaScript console (Ctrl+Shift+I)? I currently don't have a better idea where to look for this kind of error. Maybe you continue and see if the issue persists, and report back later?

MrSmith35 (talkcontribs)

Hi,

Yes there is an output in the console but nothing that comes up as an error related to the actions when adding a template neither in the Main namespace nor in the User namespace, both consoles look pretty much the same.

The problem I'm seeing might be completely unrelated to the TemplateData extension in as much as I did previously have an error in the User namespace adding pages that had a "/" in their name eg User:MrSmith35/sandbox - I read that on some setups the slash could cause errors with Apache 2.4, but I fixed that by adding something to the Apache server config - what I'm seeing with templates not rendering might be something to do with how my server is configured.

I don't need templates in the user namespace so for now I can live with it, see what happens. If you do think of anything that might help resolve this or come up with a suggestion of where we might find the error logging, then I'm more than happy to help in any way I can. If I get time I might try a docker install of MW on my Synology which might give me an easier ride through the installation process than the hodgepodge of methods I had to use to get it working. If the error occurs in docker then it's probably worth investigating.

Thanks again for your help and the great work on the extension.

Reply to "TemplateData Editor suggested values input field not showing"

Including templatedata within another templatedata

5
Summary by Tinss

Use the #tag directive on the root templatedata and then use it like a normal template.

Tinss (talkcontribs)

I have several templates on my wiki that define the exact same fields through some sort of inheritance pattern/mixin. When updating those fields in the parent templates, I need to go over each child's templatedata to update the doc.

Is there a way to include a templatedata structure within another one?

Thiemo Kreuz (WMDE) (talkcontribs)

In theory, yes. Since the <templatedata> block is part of an otherwise normal wikitext page, it's possible to create a template that somehow generates this <templatedata> block's source code. And templates can call each other. However, this does have disadvantages, like not being able to use the build-in TemplateData editor any more.

A specific TemplateData feature to do something like this doesn't exist at the moment.

Tinss (talkcontribs)

Thanks for the advice. Indeed that would make it work. Having a JSON parameter that lets a user merge one templatedata block into another would be a better solution though. When I get some time, I'll look into adding that feature to the code base.

Thiemo Kreuz (WMDE) (talkcontribs)

I understand the idea, but don't think it can be done this way. Mostly for performance reasons as well as complexity. The existing mechanisms to give pages access to each other are templates and Lua modules. Introducing a new way is not a simple task.

Tinss (talkcontribs)

Got it. I ended up doing of bit of experimentation and manage to get it to work using templates only. This trick is to define your root templatedata using the #tag directive so it does not trigger an invalid JSON error.

For a live example, see my wiki.

Cannot add complete/concise TemplateData to templates that accept many numbered parameters

2
Summary by Thiemo Kreuz (WMDE)
Sdkb (talkcontribs)

For templates like w:Template:Multiple image and w:Template:Maplink, there can be an arbitrary number of parameters for images in the collage or points on the map. TemplateData does not currently seem to have a way to handle this; the best that can be done is to add TemplateData manually up to a dozen or so, which covers most use cases. However, this is tedious, first of all, and it clutters the documentation by creating a bunch of repetition. There are a lot of templates like this, so I'd like to see this fixed at some point.

Thiemo Kreuz (WMDE) (talkcontribs)

Yes, this is a known limitation, see phab:T54582. I'm afraid there are currently no plans to work on this.

Reply to "Cannot add complete/concise TemplateData to templates that accept many numbered parameters"

Small bug with warning message

6
Summary by Whatamidoing (WMF)
Sdkb (talkcontribs)

When I edit a template that has a TemplateData block on its documentation page, a warning appears ("Please note: there is already a TemplateData block on the related page"). However, when I edit a section of the documentation when there is already a TemplateData block in a different section, no such warning appears. This isn't the biggest issue, but it'd be nice to rectify. (It'd also be nice if, instead of a distracting warning, clicking on the button just redirected you to edit the documentation page; this would reduce both banner blindness and errors.)

Whatamidoing (WMF) (talkcontribs)

I think I've followed all of that, but could you give me a link so I can try it out?

Sdkb (talkcontribs)
Whatamidoing (WMF) (talkcontribs)

Right now:

  • If you edit the 'wrong' page, it warns you that TemplateData is present on the 'right' page.
  • If you edit a section of the 'right' page, it does not warn you that TemplateData is present in a different section of this page.

You propose:

  • (No change for the first point)
  • Adding a warning that TemplateData is present in a different section.

I wonder if this might be more annoying overall. There are almost 50 sections on that /doc page. I imagine that most people aren't trying to change the TemplateData (unless they're editing the TemplateData section itself). I think adding this warning might produce complaints about an "irrelevant" warning. I can imagine editors saying "Why is it telling me that TemplateData is in another section? I already know that! If I cared about TemplateData, I'd be editing the section named ==TemplateData==!"

Sdkb (talkcontribs)

Yeah, I think that speaks somewhat to my point in the parenthetical above. There's no strong need to have it at the main template, either; editors could make a similar point about it being irrelevant there. Instead of the existing workflow, I think it would be better if there was initially no warning, but if someone clicks the Manage TemplateData button, a notice pops up saying "There is already a TemplateData block on the documentation page/in another section. Click proceed to edit it there (you will lose any unsaved work)." That would be better since it'd then only affect people actually trying to edit the TemplateData, so the banner blindness would be significantly reduced.

Tacsipacsi (talkcontribs)

The proposed solution with the TemplateData editor adding the warning (instead of the static warning banner) looks good, with one exception: if someone adds a TemplateData block manually, without the wizard, they’re not warned. Probably this use case is rare, but possible; for example importing TemplateData from another wiki/page is much more convenient using copy&pasting wikitext than with retyping everything in the wizard.

Reply to "Small bug with warning message"