Help talk:TemplateData

About this board

Previous discussion was archived at Help talk:TemplateData/Archive 1 on 2015-09-04.

teaching the case 'no parameter'

5
Summary by Wladek92

ok stored in the description.

Wladek92 (talkcontribs)

when the template has parameters I can fill the array of templatedata => ok

but when all parameters are optionnal i cannot indicate it in the template data since a parameter name is always mandatory. How can i inform this case ?

thanks. --Christian 🇫🇷 FR (talk) 08:21, 5 April 2024 (UTC)

Thiemo Kreuz (WMDE) (talkcontribs)

I'm not exactly sure what the problem is, but I suspect you want "params": {}.

"Optional" parameters – i.e. parameters that are neither required nor suggested – shouldn't be a problem.

Wladek92 (talkcontribs)

that is for need to describe the defaut behaviour of the template when no parameter is provided. Where to put this information in the template data ?

Ponor (talkcontribs)

"description": "..." perhaps?

Wladek92 (talkcontribs)
Summary by Wladek92

wrong user syntax. done.

Vestrian24Bio (talkcontribs)

Hi! I tried creating a TemplateData here; But I couldn't save it due to the "Syntax Error in JSON" so, I kept it as a coding for now; could someone please review it and tell me how to fix it.

Jonesey95 (talkcontribs)

If you follow the "help" link, it takes you to a page that links to https://jsonlint.com/ which is a helpful tool.

Vestrian24Bio (talkcontribs)
Wladek92 (talkcontribs)

Invalid JSON! Error: Parse error on line 80: ...quired": true }, } "description": "P


^

Expecting 'STRING', got '}'

=> remove the ',’

Wladek92 (talkcontribs)

Hi, i just try to use a template update adding french wordings. It is ok. I recommend to use the template data button at the top of the frame. It opens graphic web interface and make the declarations for you automatically rather than to update/copy the source text manually which becomes complicated as more indentations occur. No obvious error were detected in this tool so that your Json error is probably comming from wrong syntax. --Christian 🇫🇷 FR (talk) 06:11, 23 May 2024 (UTC)

Suggestion of a new Custom format for fullwidth characters

5
Summary by Thiemo Kreuz (WMDE)

Not possible due to consistent behavior across operating systems, fonts, and the software used.

Pikakapi (talkcontribs)

Hello, this extension is very useful to use, but there is one problem in fullwidth characters.

Fullwidth characters use two space, so I can't make a custom format that all parameters align in same length.

Tacsipacsi (talkcontribs)

Actually, fullwidth characters aren’t exactly two spaces wide, at least not using my font (DejaVu Sans Mono). In the below example, I tried to use two spaces per fullwidth character, and the four spaces are wider than the two letters:

{{Template
|ABC= 
|A    = 
}}

Given this, I’m not sure how feasible such a format would be. In any case, feature requests should be raised on Phabricator if you want them to be noticed by developers.

Pikakapi (talkcontribs)

Thank you for letting me know.

I'm use to my wiki's font which fullwidth = 2 spaces, so I forgot about that.

Whatamidoing (WMF) (talkcontribs)

Pikakapi, what languages do you write in?

Pikakapi (talkcontribs)

Korean

Summary by Thiemo Kreuz (WMDE)

Not enough information. The template data is probably on a /documentation subpage.

BoldLuis (talkcontribs)

Why do not automatically appear parameters when editing templates in Wiktionary (using the "Edit Template Data" button, in the left corner when editing the template)?

Thiemo Kreuz (WMDE) (talkcontribs)

What exactly are you trying to edit?

Don't list the contents in the form of tables

3
SolidBlock (talkcontribs)

I find in this page, there are many tables to show the usage of parameters. I don't think using table is a preferred way. It is hard to read and unfriendly in mobile views.

For example:

parameterdescriptionexample
aliasesdescription of aliases<syntaxhighlight>...</syntaxhighlight>

The better way to present content may be:

=== aliases ===
description of aliases

Example:
<syntaxhighlight>...</syntaxhighlight>
Whatamidoing (WMF) (talkcontribs)

TemplateData is stored in machine-readable JSON, and I think that JSON might create the tables.

Tacsipacsi (talkcontribs)

The complaint is not about TemplateData, but about the wikitext page Help:TemplateData – to be exact, about Help:TemplateData#Template data parameters. (By the way, even if it was about TemplateData itself – JSON doesn’t create tables, it’s just a format for storing data. Those tables are created by PHP code that was programmed to create tables, but which could just as well be programmed to create definition lists or whatever format we want.)

Reply to "Don't list the contents in the form of tables"
GhostInTheMachine (talkcontribs)

Many of the examples under the "Custom formats" section show two parameters that are 3 characters long – bar and qux. Please can the examples be adjusted to use both a short and a long parameter name — GhostInTheMachine talk to me 14:23, 31 August 2023 (UTC)

Jonesey95 (talkcontribs)

Done. Good idea.

BoldLuis (talkcontribs)

All TemplateData would include a link to Wikidata.

Whatamidoing (WMF) (talkcontribs)

Why?

185.127.147.131 (talkcontribs)

Because can be used in other projects.

BoldLuis (talkcontribs)

Without retyping all the data, fields an information.

Whatamidoing (WMF) (talkcontribs)

I don't think I understand your suggestion. This is the TemplateData for the English Wikipedia's "citation needed" template:

<templatedata>
 {
 "description": "The template is used to identify claims in articles, particularly if questionable, that need a citation to a reliable source.",
 "params": {
 "date": {
 "label": "Month and year",
 "description": "Provides the month and year of the citation request; e.g., 'January 2013', but not 'jan13'",
 "type": "string",
 "autovalue": "{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}",
 "suggested": true
 },
 "reason": {
 "label": "Reason for citation",
 "description": "A reason as to why, or for what content, the citation is needed; use single quotes, if any",
 "type": "string"
   }
  }
 }
 </templatedata>

No editor or reader at any article ever sees that. I don't think it makes any sense to add a Wikidata link to the TemplateData.

Are you looking for a sort of magic infobox, so that you can type {{infobox}} and Wikidata fills in all the fields for you? That already exists, and it has nothing to do with TemplateData. Have a look at w:es:Jimmy Wales for an example of a long infobox that is mostly pulled from Wikidata.

BoldLuis (talkcontribs)

From your example : "description": "The template is used to identify claims in articles, particularly if questionable, that need a citation to

It would be translated to other language, I e. Spanish:

"description": "La plantilla se usa para identificar afirmaciones en artículos (and so on...)

So, this translation into Spanis of the template can be used in Wiktionary in Spanish, Wikipedia in Spanish, Wikibooks in Spanish... Translate once, use in several places.

On the other hand, this is seen in a forms way, when editing TemplateData.

BoldLuis (talkcontribs)

TemplateData editor method

This is the simpler way to add or edit TemplateData, possible for inexperienced users. </translate>

The TemplateData editor is a graphical user interface for adding and editing TemplateData. It is part of the TemplateData extension. It is accessible by going to any template's page (or documentation subpage) and clicking "Edit" or "Edit source".

After clicking "Edit" or "Edit source", you will see a button above the editing area and page title that says "Manage TemplateData".

Clicking this button will enter the TemplateData editor. If the page you are on already contains TemplateData, this will automatically show here. A screenshot of the TemplateData editing tool

Whatamidoing (WMF) (talkcontribs)

Because we don't have Global templates, it's unlikely that anything would get re-used in multiple places.

BoldLuis (talkcontribs)

We can use TemplateData in Wikidata for templates in all sister projects and so, the template documentation can be reused in multiple sister projects. Translate once, reuse several times. Also could be used the Wikifunctions wiki.

This post was hidden by Tacsipacsi (history)
Reply to "Wikidata"

Help with finding TemplateData's with errors

3
Shushugah (talkcontribs)

I recently fixed TemplateData on en:Template:Infobox organization but did not find an easy way to search for other potentially affected templates with errors, particularly high trafficl ones. Is there a tracking category for this? Shushugah (talk) 19:09, 13 September 2021 (UTC)

Whatamidoing (WMF) (talkcontribs)
Izno (talkcontribs)

If by "fixed TemplateData" Shushugah means this set of edits, no, there is no way to detect this.

Reply to "Help with finding TemplateData's with errors"

TemplateData in user space?

9
Summary last edited by ExE Boss 00:33, 5 November 2021 3 years ago
Vexations (talkcontribs)

I've tried to add TemplateData to a template in my user space, but couldn't get it to work. To make sure the problem wasn't with my template, I copied an existing one that worked on enwp {{0}}, and found that it stopped working when I tried to place the TemplateData in User:username/templates/template/doc. Does TemplateData only work in the Template namespace? Thanks, ~~~~

ExE Boss (talkcontribs)

Note that you also need to transclude the documentation subpage into the User template page for it to work, e.g.: {{m:User:ExE Boss/OtherProjects}}.

Vexations (talkcontribs)

Thanks, yes, that's a good point, but I think I had that right: immediately at the end the last line of the template, I called had the documentation template embedded in a noinclude tag. The working template that I copied also did that, but stopped working in user space.

ExE Boss (talkcontribs)

Right, I forgot to mention, that you also need to perform a null edit/hard purge of the User template page, in order to properly update the templatedata page property (the TemplateData  extension does this automatically in the Template namespace when editing the doc[1] subpage).

References

Jonesey95 (talkcontribs)

It is always helpful to link to an example page when you are asking for technical help.

Vexations (talkcontribs)

Thanks for helping everyone! It's fairly easy to reproduce: Copy the 0 template (I just chose that because its one of the first in the list of templates that use TemplateData) and its doc subpage to your userspace. Now try to edit your sandbox with the Visual Editor and add the 0 template. My version that demonstrates the problem is at en:User:Vexations/templates/PB

Tacsipacsi (talkcontribs)

It doesn’t work in VisualEditor indeed, but it seems to be a bug in VE, not TemplateData: when I open your user subpage’s talk page in VisualEditor and try to insert the user subpage, no TemplateData is provided (and not even the title is visible in the autocomplete for the template name), while if I use the wikitext editor’s template inserter , it works perfectly.

Whatamidoing (WMF) (talkcontribs)

Pinging @Johanna Strodt (WMDE), because this is probably not related to WMDE's work on templates in VisualEditor, but it might be useful to know about anyway.

Johanna Strodt (WMDE) (talkcontribs)
Reply to "TemplateData in user space?"

Visual Editor corrupts TemplateData-generated transclusions on save, when not using short URL format

4
Summary last edited by Clump 21:59, 2 July 2021 3 years ago

As tracked in the referenced Phabricator bug, the Visual Editor does not support "long" URLs of the form https://site.name/index.php?title=Page_name. Only so-called "short" URLs, e.g. https://site.name/wiki/Page_name, are compatible with Visual Editor.

Bjsdaiyu (talkcontribs)

MW 1.35.0, TemplateData 0.1.2

I have templates defined using TemplateData. Filling in and editing these templtates works fine in Visual Editor (VE) up through the first save, for example this image, but upon subsequent edits it cannot find the template as shown here: it strangely believes that :index.php?title=Template:<Template Name> is the name of the Template page! Any thoughts

FeRDNYC (talkcontribs)

Hmm. A few questions:

  1. What does the "Generated from:" text show in the popup box for the template, when you commit the data edits in the Visual Editor (before you save)?
  2. What does it show after you save, then edit the page again?
  3. If you switch to Source Editing while you're re-editing the page, does it show the correct template transclusion, e.g. {{Cite book|something=|something_else=|...}}
  4. What is the URL format for your wiki? Like, what's the actual URL to Template:Cite book? What's the URL for the article you're editing?

On Wikipedia, Template:Cite book lives at https://en.wikipedia.org/wiki/Template:Cite_book.

So if I'm editing https://en.wikipedia.org/wiki/The_Cat_in_the_Hat and want to cite Dr. Seuss, the URL to Template:Cite Book has the same https://en.wikipedia.org/wiki/ prefix. Same for the article's edit interface, which loads from https://en.wikipedia.org/wiki/The_Cat_in_the_Hat?action=edit

But it looks like either your wiki is using old-style index.php?title= URLs and the Visual Editor is mishandling those, or something is configured to think the URLs should be index.php?title=-style when they're not. (Are there any rewriting rules / HTTP redirects configured on the wiki's web server, for article paths?)

GeoffreyHfr (talkcontribs)

I have the same problem. I just found a bug logged pointing at the no-usage of Short URL :

https://phabricator.wikimedia.org/T270219


They give some workaround.

I have just added $wgUsePathInfo=true; to my LocalSettings.php for it to work.

FeRDNYC (talkcontribs)

Ooh, good find @GeoffreyHfr, that bug clearly describes exactly the problem here. According to the info there, Visual Editor simply doesn't support index.php?title= URLs, period. Apparently it never has, since Wikipedia has used short URLs since long before Visual Editor became a thing.

(Might be nice if that was documented somewhere prominent, or if it had some way to detect those URLs and at least display a helpful error message. Still, at least now people have this bug to refer to, so that's something.)

Reply to "Visual Editor corrupts TemplateData-generated transclusions on save, when not using short URL format"
Return to "TemplateData" page.