Extension talk:TemplateData

About this board

"Params" but "Param object"

9
W like wiki (talkcontribs)
Thiemo Kreuz (WMDE) (talkcontribs)

I agree it's not very easy to understand, but I'm not sure what you are missing. "sets": [] is an array of set objects. A single set object is described below.

Same for "params": {}, except it's not an array but an object that maps parameter names to param objects.

"maps": {} is documented a little different, as a single thing. The descriptions and examples are correct, as far as I can see.

W like wiki (talkcontribs)

Ok Thiemo, thanks for your answer! So Params and sets end in "s" because it is the plural and can contain several parameterS and setS. The "s" in maps is not because there are several maps but because "it maps" something (3rd person), right!?

Thiemo Kreuz (WMDE) (talkcontribs)

"maps" also contains a set of map objects. I updated the text a bit to hopefully make it a bit more clear.

W like wiki (talkcontribs)

Ok, thx Thiemo! Your edits helps, but for maps I still try to find the logic (I am not a programmer, my view is more the one of someone who tries to understand), so:

Thiemo Kreuz (WMDE) (talkcontribs)

Do you plan to work with Citoid or another tool that relies on maps? I find that maps are best understood when approached from that side.

W like wiki (talkcontribs)

No, i found here because I was working on the doc page of C:Template:TemplateBox and I am generally interested in good doc or help pages, and here for me it is still not clear. In chapter "TemplateData object" it is explained:

"Maps (Structure) containing map objects"

so both are different but map objects links to the chapter called Maps Structure. So which of both is described there? Not so clear. Thx

Thiemo Kreuz (WMDE) (talkcontribs)

I really don't know what else I could add. "maps" is a single data structure that goes multiple levels deep. The first level lists consumers by name. The next level lists parameters as they are known by the consumer and maps them to one (as a string) or more (as an array) parameters as they are named in the template.

The consensus seems to be to call the second level in this data structure a "map object".

Not really related, but if you are interested in helping others a good place to start is to convince the community that cryptic parameter names like "1d" or "1sv" are an entirely unnecessary barrier.

W like wiki (talkcontribs)

Ok thank you! I think thats make it clear. I posed a short introduction to the section with your point, I think that also helps others.

And yes, "1d" and "1sv" are really short, I agree with you, was not my creation and I have not the rights to make such big changes for a so widely used template. But in commons many widely used templates using very short parameter names.

My point to make it better (and not having the rights to change the parameter names) is to place comments into a second copy-paste-form (>>my work), because the auto-generated one don't offers this. So if you can help, to introduce this oportunity to TemplateData to place help comments for the parameters in the autogenerated copy-paste-template would be very helpfull! Beste Grüße!

Reply to ""Params" but "Param object""

Do we need this? or can we improve?

3
W like wiki (talkcontribs)

Hello, the question is a bit provocant, I know, but

1) On Commons e.g. there is Commons:Template:TemplateBox which shows a similar table like this extension but with possible links (or wiki markup like italic or code). People like writing descriptions like they are used to (with links, wiki markup,...). Now it is a lot of work, just to write a second version of this description so that all the tags are not visible and the links too. Do we need this Sisyphus work? For Example in Commons:Template:F/doc

| 2d-en  = [[#Display Name|Any text]], default is the file name (parameter #1). If there is no alternate text the parameter #2 instead can hold the first [[#option|option]].
| 2d-td-en = Any text, default is the file name (parameter #1). If there is no alternate text parameter #2 instead can hold the first "option".

2) For a good and helpful parameter description it can help a lot to state a link to another example or to a help pages with more regarding informations. This is not possible with this TemplateData Extension. (see also #How to enable wikitext within descriptions?)

PS.: I think it is the problem with the unsupported wiki markup that led to separate templateBox templates on Commons or other wikis. Normally a unified centralized solution is much better I think but when it has this important weakness, people find their own way and now on Commons the Extension:TemplateData is just collapsed (not visible first) because of the reasons above. Best Regards --W like wiki (talk) 17:20, 10 February 2024 (UTC)

Wargo (talkcontribs)

These data are mostly needed for tools such as VisualEditor to provide help during inserting templates. The solution with hidden TemplateData may be good if you have another template to display parameters, and you can generate it automatically to not duplicate work.

W like wiki (talkcontribs)

Ok @Wargo, thank you for the answer! Yes, VisualEditor for TemplateData is fine! The Automatic generation does not work, because the templates accepting wiki mark up, template data not. What do you think, will it be possible somewhen or will it never work to integrate wiki markup? I don't like dublicate work. Best Regards --~~~~

Reply to "Do we need this? or can we improve?"

Add undocumented parameter not shown

2
Role-end (talkcontribs)

MW version: 1.41

I have a template where I use a loop to iterate over all parameters with a certain name (opt1, opt2, ...). The opt1 is a optional parameter and is shown translated. If someone would like to add more options they just have to add an undocumented parameter with opt2,opt3, and so on. This is working without any problems. But since the update to V1.41 until there are no undocumented parameters added, the buttonlink with "add undocumented parameters" is not shown.

The hotkey for adding is working so pressing ctrl+shift+D will make the link visible. After adding a new undocumented parameter the link stays visible.

I am not sure if this is a topic related to the TemplateData Extension or the VisualEditor.

Tacsipacsi (talkcontribs)
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)

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

$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"