Help talk:Template/Archive 5
This is an archive of past discussions about Help:Template. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | ← | Archive 3 | Archive 4 | Archive 5 |
Whitespace in template names?
I've noticed some uses of templates (e.g. infoboxes) that include trailing whitespace (usually a newline) after the template name. This article suggests that only named parameters have whitespace trimmed, though it seems that template names do as well. Is this correct? Rriegs (talk) 17:19, 28 June 2017 (UTC)
- That is correct. Template names, like other page names, cannot start or end with whitespace characters so if whitespace wasn't trimmed/ignored around the template name in a call then no template could be called. The only alternative to trimming would be to disallow whitespace but programming languages usually allow whitespace between syntactic elements. PrimeHunter (talk) 21:59, 28 June 2017 (UTC)
Malfunctioning tennis template
Would someone take a look at this template query from the Tennis Project talk page. Seems strange to me, but with all the experts here I'm sure it's a simple explanation. Thanks. Fyunck(click) (talk) 10:27, 9 August 2017 (UTC)
Template error at Greensboro College?
Can someone please take a look at Greensboro College? There is some text at the bottom of the article that I think is coming from a (malfunctioning or vandalized?) template. Thanks! ElKevbo (talk) 19:47, 26 September 2017 (UTC)
- @ElKevbo: Not vandalism, more likely a misunderstanding of what
<noinclude>...</noinclude>
does. The problem was this edit by Jweiss11 (talk · contribs) which I have fixed; it also affected Spartanburg High School. --Redrose64 🌹 (talk) 20:48, 26 September 2017 (UTC)- Redrose64, I understand how noinclude and includeonly tags work. Looks like I accidentally removed the opening noinclude tag with that edit. Thank for making the fix. Jweiss11 (talk) 21:23, 26 September 2017 (UTC)
- @Redrose64: Thanks for the very prompt response and assistance! Much appreciated. ElKevbo (talk) 21:24, 26 September 2017 (UTC)
Help! Wikilink not working
I created Template:Location of North Korea's Nuclear tests. There are Wikilinks such as 2006 in the template and the wilinks work in the Template:Location of North Korea's Nuclear tests page. However I placed the template in an article, the wikilinks were disabled. What's wrong with the template?―― Phoenix7777 (talk) 04:01, 28 September 2017 (UTC)
- @Phoenix7777: Nothing! The article just needed to be purged to pick up the latest version of the template. -- John of Reading (talk) 05:43, 28 September 2017 (UTC)
- @John of Reading: Thanks a lot! The wikilinks were enabled.―― Phoenix7777 (talk) 07:54, 28 September 2017 (UTC)
Categorisation by inclusion
I notice that Help:Template#Categorize pages by template inclusion mentions that "placing articles into ordinary content categories [using category definitions] is discouraged". Can anyone point me to some details on why this is? I was considering experimenting with {{Infobox U.S. Presidential Document}} to try and automate categorisation by signing President, but I'll gladly leave it alone if it's not advised. — Sasuke Sarutobi (talk) 13:47, 27 March 2018 (UTC)
Can't find help on {{#section:}}
I found template usage, similar to {{#if:}} expression. It is used here: Calgary Roughnecks#Current roster. Could you please point me to some documentation of {{#section:}}? —andrybak (talk) 13:42, 20 August 2018 (UTC)
- It's not a template but a parser function (the hash is the giveaway). See Help:LST. --Redrose64 🌹 (talk) 19:49, 20 August 2018 (UTC)
Proposal to make TfD more RM-like, as a clearinghouse of template discussions
Please see Wikipedia talk:Templates for discussion#RfC: Proposal to make TfD more RM-like, as a clearinghouse of template discussions. — SMcCandlish ☏ ¢ 😼 05:18, 27 February 2019 (UTC)
This has never worked properly, since it was set up (and used in at least one article) in 2011. At least for me, the dates display in an otherwise empty top section. I know nothing about templates, but I suspect the mistake is quite simple. Can anyone help? Johnbod (talk) 18:06, 27 October 2019 (UTC)
- @Johnbod: It uses
{{Graphical timeline}}
, so have you tried the talk page for that, Template talk:Graphical timeline? Failing that, perhaps WP:HD or WP:VPT. --Redrose64 🌹 (talk) 21:08, 27 October 2019 (UTC)- Ok, thanks. I can see a long trip ahead. Johnbod (talk) 00:00, 28 October 2019 (UTC)
Citing sources
Many templates provide content which amount to assertions, and cite supporting sources. There is some discussion related to this currently in progress at Wikipedia talk:Templates#Refs in templates. Though it has not been discussed explicitly there, that discussion effectively contemplates relevant additions to this guide. Please consider participating in that discussion. Wtmitchell (talk) (earlier Boracay Bill) 14:31, 12 April 2020 (UTC)
Help:Template categorization
Help:Template categorization, as independent page is much needed, because for me it is difficult to find the main template categories signification (for example, to answer the question: in which category put this template?). --BoldLuis (talk) 19:33, 28 April 2020 (UTC)
- BoldLuis, there is Template:Wikipedia templates. —andrybak (talk) 14:27, 8 May 2020 (UTC)
Adding a source column to a template
An editor suggested here that it would be useful to include references in the list tables in articles such as List_of_colors:_A-F. I think that's worth investigating, and intended to create a shadow draft to test it out.
I was quickly stymied by the fact that the table is generated by a template, so I cannot simply attach a new column to the table.
I took a stab at creating new templates that would permit inclusion of a source:
- {{Colorts}}
- {{Colorts/Color}}
(Where the additional "s" signifies "source")
However, my limited template skills kept me from being successful. I was originally thinking of a column that would simply contain a url, but after looking at {{COVID-19 testing}}, I realize I should generate a proper reference, but trying to borrow that code failed abysmally.
I wonder if someone might be willing to help create templates that work. It also occurs to me that one option is to add a switch to the existing templates ( {{Colort}}, and {{Colorts/Color}} ) to indicate whether that template should have a sources column, but I didn't want to mess those templates up, and it is possible we will conclude the whole concept isn't workable so that's why I was starting with new templates.--S Philbrick(Talk) 18:49, 11 May 2020 (UTC)
- You may be interested in a somewhat-related discussion at Wikipedia talk:Templates#Refs in templates. I think the current gist of that is that source citations in templates ought to be placed there quietly and not made visible to transcluding articles. I personally think that is not in keeping with WP:V, but that's just my opinion. Wtmitchell (talk) (earlier Boracay Bill) 22:42, 11 May 2020 (UTC)
- An optional
source
parameter should certainly use the existing templates to avoid duplicate maintenance. I have implemented it with the wide format (not withnarrow=true
).[1][2][3]source=yes
in {{Colort}} adds a "Source" header.source=yes
in {{Colort/Color}} adds an empty cell under the source header. Any other value adds the value in the cell. Example:
Name | Hex (RGB) |
Red (RGB) |
Green (RGB) |
Blue (RGB) |
Hue (HSL/HSV) |
Satur. (HSL) |
Light (HSL) |
Satur. (HSV) |
Value (HSV) |
Source |
---|---|---|---|---|---|---|---|---|---|---|
Absolute Zero | #0048BA | 0% | 28% | 73% | 217° | 100% | 37% | 100% | 73% | |
Acid green | #B0BF1A | 69% | 75% | 10% | 65° | 76% | 43% | 76% | 43% | [source] |
- Without the source parameter to check it still works:
Name | Hex (RGB) |
Red (RGB) |
Green (RGB) |
Blue (RGB) |
Hue (HSL/HSV) |
Satur. (HSL) |
Light (HSL) |
Satur. (HSV) |
Value (HSV) |
---|---|---|---|---|---|---|---|---|---|
Absolute Zero | #0048BA | 0% | 28% | 73% | 217° | 100% | 37% | 100% | 73% |
Acid green | #B0BF1A | 69% | 75% | 10% | 65° | 76% | 43% | 76% | 43% |
- The example is the first rows in List of colors: A–F. PrimeHunter (talk) 00:09, 13 May 2020 (UTC)
Erroenous statement?
Hello, I don't understand that sentence.
Note the default text must be real text: that you cannot assign another parameter as the default. It will simply return the name of the parameter as text.
{{{Date of death|{{{Date of passing|}}}}}}
should work without any problem, no ?
Lofhi (talk) 13:48, 26 June 2020 (UTC)
- Lofhi, it might have been meant to deter readers from using something like
{{{Date of death|date-of-death|Date of passing}}}
, where parameter aliases are just separated by a pipe character. —andrybak (talk) 18:32, 26 June 2020 (UTC) - Lofhi, I've rewritten the paragraph and removed the unhelpful hidden HTML comments. —andrybak (talk) 18:39, 26 June 2020 (UTC)
- @Andrybak : all right, thank you, I think I understood the original sentence. Lofhi (talk) 11:45, 28 June 2020 (UTC)
Louis XVIII
Sockpuppet template not linking to category
Could somebody look at Dharmayya and Hanu36. My use of {{sockpuppet}} there should be causing those pages to be included in Category:Suspected Wikipedia sockpuppets of Pcsastrys5, but instead it's just producing the cat name as plain text. My template-fu is way too weak to understand what's going on there. -- RoySmith (talk) 13:51, 9 July 2020 (UTC)
- @RoySmith: Looking at the template source, the parameter is just output as it is so you have to write full category code like
cat=[[Category:Suspected Wikipedia sockpuppets of Pcsastrys5]]
. PrimeHunter (talk) 14:37, 9 July 2020 (UTC)- PrimeHunter, Hmmm. OK, I did that, and it did fix the problem. Still, it seems difficult to believe that's what was intended. -- RoySmith (talk) 14:45, 9 July 2020 (UTC)
- My searches say those are the only two pages using the parameter or the
category
alias so maybe others had problems and gave up. The parameter (originally onlycategory
) was added in 2007 [4] and has always just been output as it is. PrimeHunter (talk) 19:13, 9 July 2020 (UTC)
- My searches say those are the only two pages using the parameter or the
- PrimeHunter, Hmmm. OK, I did that, and it did fix the problem. Still, it seems difficult to believe that's what was intended. -- RoySmith (talk) 14:45, 9 July 2020 (UTC)
Greater than/less than?
Is there a way to check if a value is greater than or less than something? I would like to make a version of {{Democracy Index rating}} that uses a numeric Wikidata property to display a string based on its value. Thanks, DemonDays64 (talk) 22:58, 1 August 2020 (UTC) (please ping on reply)
- DemonDays64, This can be done using the #ifexpr construct. —andrybak (talk) 23:59, 1 August 2020 (UTC)
- @Andrybak: Thanks! Do you know if there's a way to convert a value from a string to a number? The code
{{#statements:P8328|from=Q889}}
seems to load a Wikidata value in as a string (see how ifexpr doesn't work at Special:Permalink/972194229). Thanks, DemonDays64 (talk) 18:29, 10 August 2020 (UTC)- It seems that the construct emits what appears to be a numeric value, i.e. 2.85, but examination of the page source shows that this is wrapped in two pairs of
<span>...</span>
tags -<span><span>2.85</span></span>
. We may need to push that through some kind of string replace module that will strip out those four tags. --Redrose64 🌹 (talk) 18:35, 10 August 2020 (UTC)- You could use {{digits}} to get rid of the formatting like Special:Permalink/972206910. Danski454 (talk) 20:05, 10 August 2020 (UTC)
- That's no good, it strips the decimal point: 032 thus producing a figure that is off by a factor of 100. --Redrose64 🌹 (talk) 20:27, 10 August 2020 (UTC)
- Pppery (talk · contribs) has suggested
{{#property:P8328|from=Q889}}
→ 0.32 - does that work for you, DemonDays64? --Redrose64 🌹 (talk) 20:34, 10 August 2020 (UTC)- @Redrose64: oh that works!! Thanks, you and @Pppery: :) DemonDays64 (talk) 00:29, 11 August 2020 (UTC)
- @Redrose64 and Pppery: it actually 99% works...try inserting {{Democracy Index rating/sandbox}} on Albania (one of the few articles that has the property). There's some formatting issues — can you tell what's causing them? Thanks, DemonDays64 (talk) 00:52, 11 August 2020 (UTC)
- @Redrose64 and Pppery: someone blanked it because there was a problem making a bad category, but now it's unblanked (and that part is fixed). Could you maybe take a look now please? There is a problem with a codeblock being created in the transcluded template (inspect element shows it is a pre tag if that's relevant) — any idea how this could be fixed? Thanks a lot, DemonDays64 (talk) 05:14, 24 August 2020 (UTC)!
- What is "it" that got blanked? Where are you using "it"? Always provide diffs of edits that are problematic. --Redrose64 🌹 (talk) 18:27, 24 August 2020 (UTC)
- @Redrose64: the stuff with the template being blanked is fine; I'm just saying that the test I was saying to do to see the problem with the template (in the previous thing I wrote here) wouldn't work but now it's possible to take a look and see what might be causing the bug that makes the template formatting messed up. DemonDays64 (talk) 04:41, 25 August 2020 (UTC)
- What is "it" that got blanked? Where are you using "it"? Always provide diffs of edits that are problematic. --Redrose64 🌹 (talk) 18:27, 24 August 2020 (UTC)
- @Redrose64 and Pppery: someone blanked it because there was a problem making a bad category, but now it's unblanked (and that part is fixed). Could you maybe take a look now please? There is a problem with a codeblock being created in the transcluded template (inspect element shows it is a pre tag if that's relevant) — any idea how this could be fixed? Thanks a lot, DemonDays64 (talk) 05:14, 24 August 2020 (UTC)!
- @Redrose64 and Pppery: it actually 99% works...try inserting {{Democracy Index rating/sandbox}} on Albania (one of the few articles that has the property). There's some formatting issues — can you tell what's causing them? Thanks, DemonDays64 (talk) 00:52, 11 August 2020 (UTC)
- @Redrose64: oh that works!! Thanks, you and @Pppery: :) DemonDays64 (talk) 00:29, 11 August 2020 (UTC)
- You could use {{digits}} to get rid of the formatting like Special:Permalink/972206910. Danski454 (talk) 20:05, 10 August 2020 (UTC)
- It seems that the construct emits what appears to be a numeric value, i.e. 2.85, but examination of the page source shows that this is wrapped in two pairs of
- @Andrybak: Thanks! Do you know if there's a way to convert a value from a string to a number? The code
Non-free content use
Per WP:NFCC#9, non-free content can only be used in the article namespace. However, sometimes an editor who's unfamiliar with WP:NFCC will add a non-free file to a template. I've scanned the page on templates and wasn't able to find anything related to image usage in templates. Other policy/guideline/help pages for other namespaces/template such as WP:UBX#Caution about image use, WP:UP#Non-free files, WP:DRAFTS#Preparing drafts, and WP:TPG#Non-free images do have something about this; so, I'm wondering if it would be possible to add something to H:T as well perhaps as part of a larger section related to image/file use in template. -- Marchjuly (talk) 04:26, 9 October 2020 (UTC)
Detect if the template is being used inside another template
Is there a way for the template to detect if it is being used inside another template, and not in the page's text? The goal is to detect if the template is being used inside a grammatical analysis template (in a wiktionary), and behave differently if that is the case. Thanks. --BakGF (talk) 16:02, 8 October 2020 (UTC)
- BakGF, it sounds like you want to check what is the namespace of the current page. The magic word
{{NAMESPACE}}
can be checked if that's what you want. To avoid doing this manually every time, Wikipedia has different namespace detecting templates. Technical questions about Wiktionary templates can be asked over at wiktionary:Wiktionary:Grease pit. —andrybak (talk) 19:35, 8 October 2020 (UTC)- Andrybak Thanks, but I've already tried that. On any normal article,
{{NAMESPACE}}
returns an empty string, even if the template is used inside another template inserted in the article. The goal is that, when the template is used in a normal article but inside a grammatical analysis template inserted in the article, instead of directly in the text of the article, it can detect that and behave differently. --BakGF (talk) 20:56, 8 October 2020 (UTC) - basically, to detect the caller: from where was the template invoked. --BakGF (talk) 21:14, 8 October 2020 (UTC)
- BakGF, can the outside template just a pass a parameter to the inside template, indicating the caller? For example,
|called=true
or|caller=template name
?- Code of outside template:
This is the outside template: {{inside template's name|called=true}}
- Code of inside template:
{{#if:{{{called|}}}|We have a caller "{{{called|}}}".|We don't have a caller.}}
- Code of outside template:
- —andrybak (talk) 21:35, 8 October 2020 (UTC)
- There is no automatic method. If there were, it would simplify every navbox that provides v-t-e links (and that's virtually all of them) because then I wouldn't need to make fixes like these dozens of times a month. --Redrose64 🌹 (talk) 12:58, 9 October 2020 (UTC)
- Andrybak Redrose64 Thanks. But adding a parameter is problematic because it's an existing template already used in many pages. The calls are already there in these pages. But is it possible manipulate the value of a parameter as text before it's substituted/transcluded? If that
parameter
's value is{{insideTemplate|params}}
, the goal would be to manipulate that text into{{insideTemplate|params|addedParameter=something}}
with parser functions like{{#replace:string|abc|def}}
, and only then, get the parameter's final result{{{parameter}}}
. --BakGF (talk) 12:18, 11 October 2020 (UTC)- BakGF, could you please tell what are you trying to accomplish with this? This might an instance of XY problem. What's the
grammatical analysis template
and what do you want to accomplish using this template? An example with actual Wiktionary pages will be most helpful. —andrybak (talk) 12:24, 11 October 2020 (UTC) - BakGF, also, since this involves Wiktionary templates, people who frequent Wiktionary's technical forum might be better equipped to help. —andrybak (talk) 12:32, 11 October 2020 (UTC)
- Andrybak Sure. Every word in Hebrew belongs to a general (usually 3-letter) root, the goal is to add the root's category to the page of the word. The
{{grammaticalAnalysis|params|root|params}}
template is a table displaying the word's characteristics, and it has a parameter called root, whose value is usually{{root|A|B|C}}
. The problem is that this same root template is also used inside the normal text of the pages in explanations (likesee also that other word with the different root {{root|D|E|F}}
), so it can't always add the page to the root's category. It should do that only if the root template is called from inside the article's{{grammaticalAnalysis|params|root|params}}
table. Example the word Golem. --BakGF (talk) 13:08, 11 October 2020 (UTC)- BakGF, to make sure we are on the same page, the template syntax uses two curly braces on each side. I recommend using Template:Tlc.
- As far as I understand, you want the transclusions of the "root" template to automatically categorize pages, but not all transclusions. This means that you want the "root" template to change its behavior depending on some external factor. As Redrose64 explained above with the v-t-e example, this must be done with a parameter.
- How exactly this new parameter will be passed to the "root" template depends on how the "grammaticalAnalysis" template and the "root" template interact. If the "grammaticalAnalysis" template transcludes
{{root}}
, then you need to update the code of the "grammaticalAnalysis" template. If the "root" template is passed as parameter to{{grammaticalAnalysis}}
, then every usage of{{grammaticalAnalysis}}
must be updated. Something like this:{{grammaticalAnalysis|...|{{root|...|categorize=yes}}|...}}
. —andrybak (talk) 13:26, 11 October 2020 (UTC)- Andrybak right, corrected to two curly braces. The root template is passed as parameter to
{{grammaticalAnalysis}}
, the text{{root|A|B|C}}
is entered manually by the user when creating the grammaticalAnalysis table. Updating every usage of{{grammaticalAnalysis}}
is what I am trying to avoid. And people are used to doing things that way, I am trying to do that automatically and make it as simple as possible for people who edit: in the future they're likely not to add the newcategorize=yes
parameter. Is there a way for{{grammaticalAnalysis}}
's code to get its root parameter as text"{{root|A|B|C}}"
before the root template is transcluded, manipulate that text into"{{root|A|B|C|categorize=yes}}"
with{{#replace:string}}
, and only then expand its modified parameter with{{{root}}}
? --BakGF (talk) 14:25, 11 October 2020 (UTC)
- Andrybak right, corrected to two curly braces. The root template is passed as parameter to
- Andrybak Sure. Every word in Hebrew belongs to a general (usually 3-letter) root, the goal is to add the root's category to the page of the word. The
- BakGF, could you please tell what are you trying to accomplish with this? This might an instance of XY problem. What's the
- BakGF, can the outside template just a pass a parameter to the inside template, indicating the caller? For example,
- Andrybak Thanks, but I've already tried that. On any normal article,
Confusing arrow templates
There is an accessibility/clarity problem discussed at Template talk:Tfluc-common-doc; may I ask the attention of some experts in templates? If this is the wrong forum, please feel free to move this post, and my apologies. HLHJ (talk) 02:37, 29 October 2020 (UTC)
Guide for including topics in a template?
Is there a guideline for what topics should and should not be included in a template? There is a dispute at Template:Thomas Dixon Jr.--User:Namiba 15:31, 29 November 2020 (UTC)
- @Namiba: I've posted a link there to Wikipedia:Categories, lists, and navigation templates#Navigation (WP:NAVBOX) and excerpted the content there in part. That may not exhaust all guidance on the issue, but hope it helps.--Fuhghettaboutit (talk) 17:30, 29 November 2020 (UTC)
Redundant word?
Hi. This is the first sentence found in the section “Calling”.
Calling a template is not unlike calling a variable or a function in a programming language: call it with a reference and it returns a value (the output).
So is it “unlike”, or “like”? I’d guess it’s “like”, given the context. But I’m not familiar with programming, so I seek advice. — Colathewikian (talk) 07:21, 10 November 2020 (UTC)
- It is not unlike, i.e. it is similar to a function call in a programming language. VanIsaacWScont 11:26, 10 November 2020 (UTC)
- Changed it to
Using a template is much like calling a function in a programming language ...
. Better? — GhostInTheMachine talk to me 20:32, 22 December 2020 (UTC)
- Changed it to
Includeonly nesting
Seems to be a problem (new for me) when I nest includeonly tags. Illustrated at this sandbox, I've includeonly'd the entire template, which I've done many times, and then nested an includeonly tag set in the |state=
parameter. The /includeonly closing tag in the |state=
parameter appears to close the first includeonly tag instead of just closing the second includeonly tag that is within the |state=
parameter. Haven't seen this before and it seems I'm missing something. What am I missing? P.I. Ellsworth ed. put'r there 12:43, 6 February 2021 (UTC)
- AFAIK that's how it's always behaved -
<includeonly>...</includeonly>
,<noinclude>...</noinclude>
and<onlyinclude>...</onlyinclude>
cannot nest inside tag pairs of the same type. --Redrose64 🌹 (talk) 17:29, 6 February 2021 (UTC)- Maybe it's me, but it seems like I've done it before. So I've gone all this time without noticing this until now. It's so true that there is something new to learn everyday! Thank you very much, Redrose64! P.I. Ellsworth ed. put'r there 20:05, 6 February 2021 (UTC)
Help with template formatting
Hello,
The template {{ListEntry/Song}} renders list entries for a table but by default the writer field is collapsed. This is ill advised per MOS:COLLAPSE. Can anybody support with removing this formatting? ≫ Lil-Unique1 -{ Talk }- 22:23, 16 February 2021 (UTC)
- @Lil-unique1: This template has no collapsing code, and I know of no means for collapsing individual rows of a table - if a table is collapsible, the code for that is in the outermost table element. Please give examples of where you see this partial collapse. --Redrose64 🌹 (talk) 23:56, 16 February 2021 (UTC)
- Maybe I have misunderstood then but I can see it collapsed at: List of songs recorded by Jennifer Lopez. ≫ Lil-Unique1 -{ Talk }- 11:55, 17 February 2021 (UTC)
- List of songs recorded by Jennifer Lopez does not use
{{ListEntry/Song}}
. The effect that you see in that article is not collapsing at all, but selective show/hide of part of a cell's content. Specifically, Template:ListEntry/Song/JLo uses{{hidden}}
to wrap the content of one of the cells within the row. Template:ListEntry/Song has no corresponding code: the cell content is not hidden. --Redrose64 🌹 (talk) 23:51, 17 February 2021 (UTC)
- List of songs recorded by Jennifer Lopez does not use
- Maybe I have misunderstood then but I can see it collapsed at: List of songs recorded by Jennifer Lopez. ≫ Lil-Unique1 -{ Talk }- 11:55, 17 February 2021 (UTC)
Passing parameters through nesting
Say we have templates A and B such that A = {{{p}}}, {{{q}}}
. Now, I would like to call something like {{A|p = hi|q = {{B}} }}
, but I would like template B to always output the same value as p. There is a non-ideal way to do it -- using {{Template parameter value}}, we can set B = {{Template parameter value|{{FULLPAGENAME}}|A|1|p|1}}
and call {{A|p = hi|q = {{B}} }}
. However, this would cause issues, since {{Template parameter value}} is fixed on only looking at the first instance of template A. If we tried to do:
{{A|p = hi |q = {{B}} }} {{A|p = hey |q = {{B}} }} {{A|p = hello |q = {{B}} }}
we would get the output:
hi, hi
hey, hi
hello, hi.
So, essentially, my question is: Is there a way to have nested templates such that the inner template can take parameter values from the outer template? Pbrks (talk) 00:17, 14 March 2021 (UTC)
Semi-protected edit request on 1 July 2021. Jones
This edit request to Help:Template has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
In Help:Template#Parameters, it would help if the parameters in the embedded example were in the reverse order (by avoiding confusion between the first parameter and the first, but un-named, parameter). Peter Jones (cwijones) 220.240.66.18 (talk) 05:04, 1 July 2021 (UTC)
- Not done. Where exactly? The section doesn't read confusingly to me, but I've been here a while. ◢ Ganbaruby! (talk) 19:17, 1 July 2021 (UTC)
Adding to category
I have created a template Color_deficiency_ok and I started with this template Colour_blind and edited it.
In my template I want it to add the images to this category Color_deficiency_ok which it does.
But it also add them to Images_with_problems_for_colour_blind_people which it's not supposed to do. The template I edited had this category in it but I have changed that to my needs.
Somewhere I most have made a mistake so I hope someone here can check my template and hopefully find my mistake, thanks. --always ping me-- Goran tek-en (talk) 14:10, 18 July 2021 (UTC)
- @Goran tek-en: You should only need to remove
<includeonly>{{{category|[[Category:Images with problems for colour blind people]]}}}</includeonly>
. — Pbrks (talk) 02:37, 19 July 2021 (UTC)- Thanks, perfect I didn't see that piece of code on that page before. --always ping me-- Goran tek-en (talk) 17:05, 19 July 2021 (UTC)
Linebreaks with ifs in a table - help needed
I need some help on a template, for a problem I haven't been able to solve in several days. In Category:Polling table templates, you can see the rightmost columns have too many line breaks, coming from Template:Polling table/headrow and Template:Polling table/row. The lines not used are not shown, but the line breaks between the ifs are still counted and shown in the cells. I tried using comments and brs but it hasn't worked. Can anyone find how to remove the line breaks on unused lines? Julio974◆ (Talk-Contribs) 16:44, 7 August 2021 (UTC)
- @Julio974fr: Sorted, see this and this. --Redrose64 🌹 (talk) 18:28, 7 August 2021 (UTC)
- @Redrose64 Thank you so much! Julio974◆ (Talk-Contribs) 19:46, 7 August 2021 (UTC)
Passing undefined parameter as undefined
I am doing a cleanup that involves embedding a rather complex template inside an infobox, then migrating the transclusions of the old template to the infobox wrapper. So I need to pass a large number of parameters from the infobox call into the embedded template using |parameter1 = {{{parameter1|}}}
. But I'm running into the problem where the embedded template is interpreting all of the undefined parameters being passed to it as having a defined blank value. I know there's a workaround to this, but for the life of me I can't remember how to do it, and I can't find it in any of the help files. VanIsaac, MPLL contWpWS 21:02, 25 September 2021 (UTC)
- @Vanisaac: I haven't seen a solution and can only think of an ugly hack with a side effect:
|{{#ifeq:{{{parameter1|}}}|{{{parameter1}}}|parameter1|dummyparameter}}={{{parameter1|}}}
- It uses that the parameter name in an assignment can be the result of an expression. If parameter1 is undefined then it produces an empty
|dummyparameter=
. This may cause a problem depending on the used template. Some templates call Module:Check for unknown parameters without settingignoreblank
. This will discover the empty|dummyparameter=
. PrimeHunter (talk) 00:35, 26 September 2021 (UTC)- The side effect shouldn't be a problem. Thanks for your help. VanIsaac, MPLL contWpWS 02:24, 26 September 2021 (UTC)
- And it works like a charm! This whole problem was already a form of ugly, so that hack is right at home! VanIsaac, MPLL contWpWS 02:33, 26 September 2021 (UTC)
- Damn, you weren't kidding about a large number of parameters. A few more and page size limitation could have been a side effect. PrimeHunter (talk) 04:17, 26 September 2021 (UTC)
- I may have a bit of an ignoble tendency towards brute force in programming. VanIsaac, MPLL contWpWS 06:45, 26 September 2021 (UTC)
- Damn, you weren't kidding about a large number of parameters. A few more and page size limitation could have been a side effect. PrimeHunter (talk) 04:17, 26 September 2021 (UTC)
Template:Letter reps
I'd appreciate help with an intricate template problem. I'm trying to enhance {{Letter other reps}} to include an extra table cell for British Sign Language. It calls {{Letter reps}}. I've created {{Letter other reps/sandbox}} and {{Letter reps/sandbox}}. I've also made a minor enhancement to {{Letter reps/links}} which should be harmless: it now accepts a new language "english" which so far is used only in my sandboxes. I'm passing a new optional parameter sign_img2 between the two templates. I've added debugging to the top of {{Letter reps/sandbox}}, which shows the parameter to be set correctly, and to the middle of that same sandbox, which shows that the parameter has mysteriously become empty. You can see the effect by pretending to edit Template:Letter other reps/sandbox, previewing with page A (yes, our article about a letter), and looking at #Other representations. I've checked that using {{ifnotempty}} in this way does indeed preserve line feeds as claimed. Any clues would be most welcome please. 11:33, 31 October 2021 (UTC) — Preceding unsigned comment added by Certes (talk • contribs)
- @Certes: Does [5] do what you want? PrimeHunter (talk) 03:17, 1 November 2021 (UTC)
- D'oh! I didn't spot the equals signs. Thank you very much, PrimeHunter. Certes (talk) 11:41, 1 November 2021 (UTC)
Is there a nested/transcluded template using parameter defaulting
Hi,
I read Wikipedia:Templates for discussion/Log/2021 March 6#Template:Collapsible section. It discussed the difficulty of changing lots and lots of templates. I was wondering if default options could be hidden on a called template, and if there was already an example Wakelamp d[@-@]b (talk) 07:02, 12 November 2021 (UTC)
How to handle citations in templates that may duplicate the same source in the hosting article.
Before we go with my suggestion in the talk page quotation below, is there a better solution?
The template Comparative table of Homo lineages is causing duplicate references in the text. If anyone knows how to fix this, and can, please help to resolve this problem. Thank you, Tyrone Madera (talk) 19:27, 12 December 2021 (UTC)
- Could you add names to the reference in the template and then use those names when citing the same sources in the article? You would have to choose 'non-obvious' names lest you choose one that has already been chosen for another article that contains the template too. --John Maynard Friedman (talk) 00:07, 13 December 2021 (UTC)
- I think that would work. Do you want to give it a try? Best, Tyrone Madera (talk) 00:32, 13 December 2021 (UTC)
- On further thoughts, maybe it would be wise to leave a message at help talk:templates first. I'll do that now. --John Maynard Friedman (talk) 13:22, 13 December 2021 (UTC)
Advice please? --John Maynard Friedman (talk) 13:26, 13 December 2021 (UTC)
- I suppose that the generic question should still stand but Cygnis insignis observes in this case that there is no need for the template and has simply transcluded it manually. So I have no specific need for an answer any more but remain curious about the question since undoubtedly it will occur again.
- Is Wikipedia:Substitution the answer I really wanted? --John Maynard Friedman (talk) 14:14, 13 December 2021 (UTC)
Calling other wiki templates
Hello, is it possible to call for instance {{frwiki.template_on_the_fr_wiki}}? Bouzinac (talk) 16:24, 7 March 2022 (UTC)
- @Bouzinac: No, mw:Manual:$wgEnableScaryTranscluding is disabled in all Wikimedia wikis. PrimeHunter (talk) 17:32, 7 March 2022 (UTC)
Finding alphabetic position of a parameter
Is there a function to extract the first letter of a string parameter so it can be used to select a template output based on alphabetic order? Cheers, · · · Peter Southwood (talk): 08:51, 14 July 2022 (UTC)
- Peter Southwood, Template:Str left can be used for that. Its first parameter is the text you're trying to get the letter from; second parameter is the number of characters, in your case – one. Example:
{{Str left|foobar|1}}
→ f. —andrybak (talk) 12:28, 14 July 2022 (UTC)- Thanks, Will try that. Cheers, · · · Peter Southwood (talk): 12:52, 14 July 2022 (UTC)
- Andrybak, I am having some difficulty working out how to get the parameter into Template:Str left as it {{{1}}} and is also used as part of the output in the template I am trying to write. · · · Peter Southwood (talk): 14:04, 14 July 2022 (UTC)
- Thanks, Will try that. Cheers, · · · Peter Southwood (talk): 12:52, 14 July 2022 (UTC)
Pbsouthwood, template parameters can be used unlimited amount of times in their output. For example, in your template's code:
{{#switch:{{Str find|{{{1}}}|1}}
|a=The "a" option with parameter "{{{1}}}". Parameter foo is {{{foo}}}.
|b=Option "b" repeats it three times: {{{1}}} and {{{1}}} and {{{1}}}.
|c=Option C does not use parameters at all.
}}
After that, you'll have to pass the values of parameters to your template {{template name|first parameter|foo=Value of parameter "foo"}}
whenever the template needs to be used. If I misunderstood your query, please clarify. —andrybak (talk) 14:45, 14 July 2022 (UTC)
- Andrybak, Thanks for the help, I think your explanation is close to the point,
but not the point I was missing,Looking back, pretty much right on the point PrimeHunter has sorted it out comprehensively, and I think I am on the home straight. Cheers, · · · Peter Southwood (talk): 15:36, 14 July 2022 (UTC)
- Andrybak, Thanks for the help, I think your explanation is close to the point,
- You have to specify the input string, in your case {{{1}}}. I did it in [6] and added all letters. Tests:
- PrimeHunter (talk) 15:05, 14 July 2022 (UTC)
- Thanks, PrimeHunter, It seems I was missing a fairly critical point. With that sorted out it all seems clear and simple, even obvious. When I tried that {{ str left |{{{1}}}| 1 }} the first time I got { as the output which threw me off track completely, as it is the first character of the string, so looked like I couldn't put {{{1}}} in there. Obviously I don't write enough templates to remember how to do it in between. Its use it or lose it. Cheers, · · · Peter Southwood (talk): 15:36, 14 July 2022 (UTC)
- I think I have it all sorted now, Thanks again · · · Peter Southwood (talk): 16:43, 14 July 2022 (UTC)
- @Peter Southwood: If the call has no unnamed parameter or the template page is viewed directly then
{{{1}}}
remains exactly that 7-character string where the first character is indeed{
. Templates often say{{{1|}}}
instead. If there is no unnamed parameter then{{{1|x}}}
evaluates to whateverx
is. In particular,{{{1|}}}
evaluates to the empty string. PrimeHunter (talk) 19:40, 14 July 2022 (UTC)
- @Peter Southwood: If the call has no unnamed parameter or the template page is viewed directly then
{{lambda}} is a bad example
As of February 2021, {{lambda}}, described in Help:Template#Basic template usage examples as "very simple", is anything but. If anyone knows of an example that's still simple it would be great to replace this. Dan Bloch (talk) 23:11, 4 January 2022 (UTC)
- I would suggest
{{TM}}
is probably the best option now. It inserts a single character with a link to the article[[trademark]]
. VanIsaac, MPLL contWpWS 01:51, 5 January 2022 (UTC)
- Works for me. Done. Dan Bloch (talk) 02:40, 5 January 2022 (UTC)
- I have gone ahead and requested for an edit notice to be added to
{{TM}}
in the hopes that changes to the template will get reported here so we can keep this sort of thing from happening behind our backs again in the future. VanIsaac, LLE contWpWS 02:10, 6 September 2022 (UTC)
Code and its output
I'm looking for a template that will show wikitext and its output. This would in particular be useful for Help:Score so the LilyPond code doesn't have to be written twice, with the inevitable danger of making mistakes in the repetition or losing synchronization when making changes. I had thought I would find something like that in the documentation of templates, but I haven't. {{Demo}} comes close, but a) lacks provision for <syntaxhighlight>
and I can't get it to work for <score>
at all. {{Automarkup}}/{{Make code}} is clumsy and unsuitable.
The template needs to take at least two parameters: 1) the wikitext, say |text=
; 2) a tag, say |tag=
, <syntaxhighlight lang="xxx">
, to be used for the code display. I'm hoping that the required closing tag, </syntaxhighlight>
, can be generated from the parameter |tag=
via {{first word}}. A possible third parameter to organize the two displays side-by-side would be nice, but that would then also need parameters to control the respective widths.
Here's an example:
<score sound="1">
\relative c'' { \set Staff.midiInstrument = #"bassoon" \clef treble \numericTimeSignature \time 4/4 \tempo "Lento" 4 = 50 \stemDown c4\fermata(_"solo ad lib." \grace { b16[( c] } b g e b' \times 2/3 { a8)\fermata } }
</score>
Is there such a thing, or should I attempt to write it? -- Michael Bednarek (talk) 07:30, 3 October 2022 (UTC)
<nosubst>
Why not just have a tag <nosubst> whose content is removed by subst:, so it is only displayed if the template is transcluded? (a functionality somewhat similar to <noinclude> and <includeonly>)
This way, you can display a big ugly warning to the user who misses the subst:, add the page to a special category or whatever you want. Much less intrusive than the other proposed changes.
From phab:T4003 BoldLuis (talk) 14:36, 16 November 2022 (UTC)
Template help
I'm not sure where to go with this Template question but I see here, unlike some other Template talk pages, there are some responsese to queries so here it goes.
Tonight, I ran into some problems with an editor who put CSD tags on a template that was transcluded. Soon the CSD categories were filled unrelated articles that were tagged for speedy deletion because the tagged template was put on the articles at some point. The editor had a valid CSD reason for deleting the template (G7) but tagging the template just caused a mess. I removed the CSD tag and ask them to "untransclude" the template from pages where it had been put. I'm not sure whether or not that was followed through on.
When I went to Wikipedia:Criteria for speedy deletion for some guidances on tagging templates for speedy deletion, the only discussion about templates were the templates used for CSD tagging, not templates as the pages being tagged. So, do you know of any policy guidance here? I rarely see templates tagged for speedy deletion, more often it is just template talk pages, but when templates have appeared at CSD categories they have always been unused, not transcluded. I know that transcluded templates are not supposed to be tagged CSD G5 but I didn't see this mentioned for any other type of deletion criteria. Any ideas here? Liz Read! Talk! 08:11, 5 October 2022 (UTC)
- Template: pages: place the template within a noinclude tag, like this:
<noinclude>{{Db-x}}</noinclude>
How to include wikilinks in parameter descriptions?
There are multiple attempts at wikilinks in the documentation for the parameters of Template:Infobox university but none of them work. The documentation uses Template Data. How do we fix this? ElKevbo (talk) 03:59, 12 December 2022 (UTC)
- @ElKevbo: You can't, per mw:Help:TemplateData#Template data parameters, second bullet:
Wiki markup will not work in descriptions or labels. They are strictly plain text strings.
--Redrose64 🌹 (talk) 19:39, 12 December 2022 (UTC)- Thanks for the quick reply! Are there any workarounds or options? Failing that, is there is an appropriate place to request this functionality or lodge a complaint? ElKevbo (talk) 00:35, 13 December 2022 (UTC)
- @ElKevbo: phab:T52656 is a request from 2013. PrimeHunter (talk) 02:47, 13 December 2022 (UTC)
- Thanks for the quick reply! Are there any workarounds or options? Failing that, is there is an appropriate place to request this functionality or lodge a complaint? ElKevbo (talk) 00:35, 13 December 2022 (UTC)
Is there a way to wrap around bracktes only a part?
I don't know whether is the right place to ask; anyway I need to wrap around brackets only a part of what {{Convert}} returns. In this case {{tl|{{one2a|{{convert|1|impgal|l usgal|spell=in|disp=sqbr}}}}}}
I need [imperial] bracketed (page distemper). I know there is a template {{bracket}} but the way it is it's unuseful for me.-- Carnby (talk) 18:11, 13 December 2022 (UTC)
- @Carnby: I'm not sure what you want. Please clarify it. I guess it's about Distemper (paint).
{{one2a|{{convert|1|impgal|l usgal|spell=in|disp=sqbr}}}}
produces "an imperial gallon [4.5 L; 1.2 US gal]". Do you mean you want it to say "an [imperial] gallon [4.5 l; 1.2 US gal]"? Why? PrimeHunter (talk) 20:03, 13 December 2022 (UTC)- @PrimeHunter: Yes, but I noticed later the problem of the article an...--Carnby (talk) 20:12, 13 December 2022 (UTC)
Query
Hello, Template folk,
An editor today removed a lot of sports templates for season articles stating that templates shouldn't be in categories alongside articles in regular categories. Is this the case? Are templates only placed in template categories? It emptied out a lot of categories so I wanted to double-check. There are a lot more instances I've come across of this looking at the newly tagged categories so I was wondering if more templates should be removed from regular categories alongside the ones that were handled today. Thanks. Liz Read! Talk! 22:25, 31 December 2022 (UTC)
- @Liz: This isn't a help desk, it is the talk page for discussing improvements to Help:Template. That aside, see WP:CAT#T. --Redrose64 🦌 (talk) 23:21, 31 December 2022 (UTC)
- @Liz: WP:CAT#T does say to not place templates in content categories but in many areas it's common practice that if a navigation template corresponds closely to a category then the template is placed there, either at the end under τ per WP:SORTKEY or sometimes at the start under *. If a navbox is helpful to navigate the articles and provides other organizaton than an alphabetical category, maybe also extra information, then it seems helpful to have the navbox in the category. Consider e.g. Category:2014 ATP World Tour and Template:2014 ATP World Tour. The template shows the types of tournaments with the biggest first, and it's chronological within each type. It showed all tournaments before they all got articles, and relevant articles may be missing the category or have a bad sortkey or no sortkey. I have long thought about suggesting a change to WP:CAT#T to explicitly allow useful navboxes corresponding to the category. The standard reason for omitting templates from article categories is that templates are for editors while article categories are for readers, but navboxes are also for readers. If a category is mainly meant to help readers find articles and a navbox can help them more then why omit it? PrimeHunter (talk) 23:53, 31 December 2022 (UTC)
- Well, apologies for placing this query on the wrong page, Redrose64. Thank you, your reference to WP:CAT#T addresses my question. There are quite a lot of template talk pages and not all of them are actively used. It seemed logical to go to a Help page where those editors who work with templates could see this question. I often have questions about template usage so where should those questions be posted in the future? I don't think those editors helping out at the Help Desk and Teahouse are experts on templates and policy.
- Thank you for this information, PrimeHunter, it's helpful. For further information on my issue, these are old sports season college league categories where the only pages in the category are a season page and a template page and sometimes, there is only a template in the category. If you go to Category:Empty categories awaiting deletion you can see the result of an editor removing these templates from the categories. When I was looking into it, I found a lot more of these small cats with only a template or a template and a season page so I proposed to another editor who works primarily with categories if they could check it out. But my question here was just a general question.
- I hope you both have a great New Year's Day, however you choose to spend it! Liz Read! Talk! 03:04, 1 January 2023 (UTC)
- Well, there is Wikipedia talk:WikiProject Categories, or perhaps Wikipedia talk:WikiProject Templates. --Redrose64 🦌 (talk) 09:38, 1 January 2023 (UTC)
- @Liz: WP:CAT#T does say to not place templates in content categories but in many areas it's common practice that if a navigation template corresponds closely to a category then the template is placed there, either at the end under τ per WP:SORTKEY or sometimes at the start under *. If a navbox is helpful to navigate the articles and provides other organizaton than an alphabetical category, maybe also extra information, then it seems helpful to have the navbox in the category. Consider e.g. Category:2014 ATP World Tour and Template:2014 ATP World Tour. The template shows the types of tournaments with the biggest first, and it's chronological within each type. It showed all tournaments before they all got articles, and relevant articles may be missing the category or have a bad sortkey or no sortkey. I have long thought about suggesting a change to WP:CAT#T to explicitly allow useful navboxes corresponding to the category. The standard reason for omitting templates from article categories is that templates are for editors while article categories are for readers, but navboxes are also for readers. If a category is mainly meant to help readers find articles and a navbox can help them more then why omit it? PrimeHunter (talk) 23:53, 31 December 2022 (UTC)
How to return to caller?
I can't remember (if I actually knew) how to return parts to caller. For instance, {{callee | verb | za1| za2| za3| za4| za5 }} I would like the five z.. parts returned separate. How? Auntie Kathleen (talk) 02:44, 8 January 2023 (UTC)
- I honestly have no idea what you are asking here. The only hint was a dead end: there is no template
{{callee}}
. Could you please show an example of what you mean by any of this? VanIsaac, GHTV contWpWS 03:16, 8 January 2023 (UTC)- Caller -> callee - you with me so far? - I want to know how to return results from the called [template], let's us say callee, to outer layer (caller). But how does the answer depend on the question? Auntie Kathleen (talk) 07:39, 9 January 2023 (UTC)
- You've just described the single thing that templates do. They return their result to the place they were called from, no matter where that is. If you call
{{TM}}
, it will return "™" every place you put it, whether that's in the page text or as an argument in another template call. So{{symb|{{TM}}}}
produces the results of the{{symb}}
template, a box with an enlarged text symbol displayed on the right of the page, as if you had manually typed the trademark symbol as its argument, which is what{{TM}}
returns. And this is exactly what you see on the right hand side of the page here because I used that code. VanIsaac, GHTV contWpWS 09:21, 9 January 2023 (UTC)- It's not one, is 35 different results. And how can I them all sent on to a different template? Auntie Kathleen (talk) 14:05, 9 January 2023 (UTC)
- Then you have to invoke the template 35 different times, and have a way of getting the template to output the correct one of the 35 different results, such as using help:conditional expressions. Every time a template is called, it is evaluated to a single string of wikitext exactly where it was called. That's it. If it could output 35 different results, you'd have to have some way of referring to each of the results anyway, and assigning those results to the correct calling template. Instead of doing all that, all you have to do is call the template each time. VanIsaac, GHTV contWpWS 14:37, 9 January 2023 (UTC)
- So there is no way of returning anything at all to the caller. So even in a simple case
{{doit|a}}
- a=987
- value after
{{doit}}
isn't changed. So have to do nested routines work, and what for? - Using 35 separate calls wouldn't work:
- starting position with seven items A, B, C, D, E, E, F, G then for each item with split into 5 parts (quintiles) a1, a2, a3, a4, a5 … g1, g2, g3, g4, g5
Then I want to use the parts in a different template, Y1=a1,b1,c1,d1,e1,f1,g1 Y2=a2,b2,c2,d2,e2,f2,g2 … Y5=a5,b5,c5,d5,e5,f5,g5
- starting position with seven items A, B, C, D, E, E, F, G then for each item with split into 5 parts (quintiles) a1, a2, a3, a4, a5 … g1, g2, g3, g4, g5
- At the start, the seven items in fact are coming from wikidata as 7 years of a single entity. The whole part is to use only seven passes rather than 35 (which may add further years later).
Auntie Kathleen (talk) 23:55, 9 January 2023 (UTC)
- So there is no way of returning anything at all to the caller. So even in a simple case
- Then you have to invoke the template 35 different times, and have a way of getting the template to output the correct one of the 35 different results, such as using help:conditional expressions. Every time a template is called, it is evaluated to a single string of wikitext exactly where it was called. That's it. If it could output 35 different results, you'd have to have some way of referring to each of the results anyway, and assigning those results to the correct calling template. Instead of doing all that, all you have to do is call the template each time. VanIsaac, GHTV contWpWS 14:37, 9 January 2023 (UTC)
- It's not one, is 35 different results. And how can I them all sent on to a different template? Auntie Kathleen (talk) 14:05, 9 January 2023 (UTC)
- You've just described the single thing that templates do. They return their result to the place they were called from, no matter where that is. If you call
- Caller -> callee - you with me so far? - I want to know how to return results from the called [template], let's us say callee, to outer layer (caller). But how does the answer depend on the question? Auntie Kathleen (talk) 07:39, 9 January 2023 (UTC)
Need Help
In the Infobox Indian state or territory, the label 'Capital' is displayed by default. I am attempting to prevent this label from appearing without adding any corresponding data. Despite my efforts, I have not been successful in resolving this issue due to my limited experience. Could anyone please provide guidance on where I might be going wrong? Thank you very much in advance Tojoroy20 (talk) 21:02, 21 March 2023 (UTC)
- @Tojoroy20: Yeah, this had a
<br />
tag outside of a conditional for the different types of capitals, which is interpreted as content for that field, even though it's just formatting. I moved it inside the winter capital conditional so that you only get the line break if it has the dual capitals. VanIsaac, GHTV contWpWS 21:15, 21 March 2023 (UTC)- Thank you very much for your help, for identifying the issue and fixing it. Tojoroy20 (talk) 21:44, 21 March 2023 (UTC)
Terminology: template
There's a terminology issue that I think ought to be addressed on this help page: use of the term "template".
The first sentence of the page says "template" refers to a certain kind of Wikipedia page, and then uses it consistently that way throughout.
But I know it is also common to use "template" to refer to the wikitext that calls a template, as in,
This may be accomplished by placing templates such as {{Archive top}} and {{Archive bottom}} ... around a discussion.
And also to refer to the text generated by the template in the rendered page, as in,
An extreme example of tag bombing was found at ..., which had a maintenance template saying that it had too many maintenance templates.
If these are standard usage, I'd like to put that on this help page, because this is bound to confuse any newcomer who is trying to understand templates or have a conversation about templates. And if not, maybe we can acknowledge it anyway and offer more standard wording? Bryan Henderson (giraffedata) (talk) 06:24, 25 May 2023 (UTC)
- I guess no one else has strong opinions about terminology, but I think it's pretty important, so I went ahead and added a section. I read through template documentation and looked around for common usage and came up with rigorous terminology to use when talking about templates that is as close as possible to conventional usage. I also listed common variations on that terminology.
- This help page itself isn't entirely consistent in its terminology, so I plan to tackle that next, using the terminology I have documented. Bryan Henderson (giraffedata) (talk) 20:36, 3 June 2023 (UTC)
- Do you think it just needs a good copyediting, or do you think we need something like the terminology box we have at Wikipedia:Requests for comment#Ending RfCs? WhatamIdoing (talk) 04:35, 4 June 2023 (UTC)
- I like that terminology box, but it's more important on that page because it's actually inside a section and right next to text that uses some rather arcane terms. On Help:template, I think the terminology is simple enough that if I just make a pass over the whole thing to make it consistent, it will be fine. It just suffers now from classic Wikipedia piecemeal editing. Bryan Henderson (giraffedata) (talk) 23:03, 4 June 2023 (UTC)
- I prefer the idea of starting with a copyedit. WhatamIdoing (talk) 23:59, 4 June 2023 (UTC)
- I'm not following you. You prefer the idea of starting with a copyedit to what? Bryan Henderson (giraffedata) (talk) 03:36, 5 June 2023 (UTC)
- I prefer your idea of copyediting Help:Template. I agree with you. If we clean this up to make it consistent, that should be enough. If we truly need more (e.g., a list of definitions), then that need will become apparent later and can be done later. WhatamIdoing (talk) 15:35, 5 June 2023 (UTC)
- I'm not following you. You prefer the idea of starting with a copyedit to what? Bryan Henderson (giraffedata) (talk) 03:36, 5 June 2023 (UTC)
- I prefer the idea of starting with a copyedit. WhatamIdoing (talk) 23:59, 4 June 2023 (UTC)
- I like that terminology box, but it's more important on that page because it's actually inside a section and right next to text that uses some rather arcane terms. On Help:template, I think the terminology is simple enough that if I just make a pass over the whole thing to make it consistent, it will be fine. It just suffers now from classic Wikipedia piecemeal editing. Bryan Henderson (giraffedata) (talk) 23:03, 4 June 2023 (UTC)
- Do you think it just needs a good copyediting, or do you think we need something like the terminology box we have at Wikipedia:Requests for comment#Ending RfCs? WhatamIdoing (talk) 04:35, 4 June 2023 (UTC)
show button doesn't expand template
I created and added Template:Tim Powers to Tim Powers page but when I click the show button it doesn't expand. Every other page I added the template that has other other templates like Expiration Date (Powers novel), the show button works but not on Tim Powers. Mika1h (talk) 12:44, 6 June 2023 (UTC)
- @Mika1h: I agree that it wasn't working ten minutes ago, but it seems to be working now. BTW, this isn't a help desk, it is the talk page for discussing improvements to the page Help:Template. --Redrose64 🌹 (talk) 13:39, 6 June 2023 (UTC)
Image customization possible?
{{Deceased Wikipedian}} is a template which marks user pages of deceased Wikipedians. The template uses one image.
Is it possible to develop such templates to allow any arbitrary image? Can anyone point to a template which has a field for user input of Commons images, which the template would then display instead of the default? Thanks. Bluerasberry (talk) 16:37, 7 April 2023 (UTC)
- @Bluerasberry: I think this is a good example of what you’re looking for: Wikipedia:WikiProject Spaceflight/Userbox. Note that the simplest change to DW would be something like:
− | image = [[File:Candle Memorial For Deceased Wikipedians.PNG|70px]]+ | image = [[{{{alt-image|File:Candle Memorial For Deceased Wikipedians.PNG}}}|{{{custom-image-size|70px}}}]]- Note that we are using parameter syntax to fall back to the default if the parameter is not supplied. — HTGS (talk) 22:17, 7 September 2023 (UTC)
Semi-protected edit request on 13 September 2023
This edit request to Help:Template has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
The link on text "parameters" (in text "(via parameters)" in the heading "General description") reloads the page and then navigates to section of the same page. It should be changed so it takes you to the section directly. ACaseOfWednesdays (talk) 07:58, 13 September 2023 (UTC)
- Done. -- Michael Bednarek (talk) 11:54, 13 September 2023 (UTC)
Template not working
If you go to my userpage and you click on the first DYK and fourth GA icon, they dont work but the others do. Why is that? Wingwatchers (talk) 04:39, 8 October 2023 (UTC)
- Those two had "article name" instead of "article_name". I replaced them, and they work now. MANdARAX • XAЯAbИAM 04:45, 8 October 2023 (UTC)
Collapsed State
On in the Ghost Rider: Travels on the Healing Road, I added "state=collapsed" in the Rush template on the page as it takes up a lot of space when it's visible. It didn't work. Other times, it has work when editing other articles with templates. It doesn't make sense to work sometimes and not work other times. Never inquired about this before. Need to know what to do for next time. Mr. C.C.Hey yo!I didn't do it! 00:14, 10 November 2023 (UTC)
Help
Does anyone have a full list of templates? im trying to see how many i can fit into my user page and im not sure if the template index has all of them (and i also want to find some templates that are in Help pages Whenthecat (talk) 18:18, 26 January 2024 (UTC)
- There isn't a technically complete list of templates, because what makes something a template is in the minds of its users. But essentially all templates are in the Template namespace and essentially all pages in the Template namespace are templates, so you can use Special:AllPages. Wikipedia:Database reports/Page count by namespace says there are about 375,000 of them.
- I don't know what you mean by templates in help pages.
- (For the sake of clarity, remember that a template is a page; many people use the term for other things; see Help:Template#Terminology).
- Bryan Henderson (giraffedata) (talk) 19:34, 26 January 2024 (UTC)
- Does that number include all of the /doc pages, sandboxes, testcases, and any other template subpages? If so, I would suggest that the actual number is probably no more than 1/3 of that total.
- That's a good point. I was wrong that essentially all pages in the Template namespace are templates. Bryan Henderson (giraffedata) (talk) 17:52, 27 January 2024 (UTC)
- when i mean help pages i mean any page like Help:, Wikipedia:, or any other similar pages and i used the term "help page" in an unclear way Whenthecat (talk) 20:54, 29 January 2024 (UTC)
- So what is a template in such a page? Templates don't exist within pages. Bryan Henderson (giraffedata) (talk) 21:30, 29 January 2024 (UTC)
- Does that number include all of the /doc pages, sandboxes, testcases, and any other template subpages? If so, I would suggest that the actual number is probably no more than 1/3 of that total.
Need some iPhone and Android users to look at this sticky-header table template
We especially need some iphone users to look at the test sandboxes for some proposed updates for the sticky-header template. See:
A general template tuneup would be welcome too. See anything that can be improved? Comment there please. --Timeshifter (talk) 12:18, 29 February 2024 (UTC)
- This was resolved and archived at Wikipedia:Village pump (technical)/Archive 211#Sticky header template for tables. Need iphone and Android testers. —andrybak (talk) 09:10, 23 July 2024 (UTC)
Template recursion limits
I attempted to clarify the recent change to the page's description of the restriction on a template calling itself. My change was reverted in its entirety by User:Mathglot, and I looked at the discussion at Wikipedia:VPT#Invalid detection of infinite template loop with only one level of nest and discovered that I had misunderstood the rule.
The fact that I didn't understand the restriction when I read it on this help page proves it isn't clear, and I'd like to fix it.
It appears to me that User:PrimeHunter is saying that any attempt by a template to call itself during expansion fails, but that there's no restriction on a template calling itself when the template page is being displayed itself. The ability for a template to call itself when displayed is widely used for documentation, because it means when you display a template, you can see an example of the template result.
The text as it stands is
Generally, template recursion is forbidden; that is, a template may not call itself. Attempting to do so produces an error message and causes the page to be marked by MediaWiki as having a template loop. The one exception is that a template may call itself on its own template page for the purpose of documentation.
I find this confusing because a) it's not clear whether "forbidden" is just a policy or MediaWiki implementation. This appears to say you don't get the error message if the template calls itself for documentation, as if there's some way MediaWiki can distinguish a documentation call. "Call itself on its own template page" is really confusing, because "template page" just means "template", with emphasis on the fact that a template is a page, and how would a template call itself on any other page? A call to a template on the template's own page is in fact rejected when you try to expand that template (page).
Also, I don't understand what "marked as having a template loop" means. Where is this marking?
How about this:
Template recursion does not work. Expansion of a template that calls itself fails with an error message. However, you can display a template page directly that contains a call to itself, and this is widely done for documentation, so the reader of the page can see an example of the template result.
Bryan Henderson (giraffedata) (talk) 04:21, 25 February 2024 (UTC)
- @Giraffedata: See this instance of Template:X14. It displays a message similar to: Template loop detected: Template:X14. It's also in Category:Pages with template loops. --Redrose64 🌹 (talk) 20:25, 24 February 2024 (UTC)
- Giraffedata, Thank you for bringing this here. I agree that "forbidden" is ambiguous, and perhaps "not supported by mediawiki software and returns an error" is better. {{X14}} is an obvious case because it calls itself directly, but earlier, I had created templates Draft:Recur-A and Draft:Recur-B to clear up any misunderstanding about whether the issue is merely direct vs. indirect calls, to show that neither is permitted. You can't determine that from X14 alone, but you can see that indirect loops also throw errors here:
{{Draft:Recur-A|oops}}
⟶ Draft:Recur-A
- But at this point, it sounds like we are just trying to find the right wording, is that your view as well? If so, then I believe briefer is better, and the fewer words we can use to say that except for Template doc it won't work so don't even try, the better. Mathglot (talk) 22:18, 24 February 2024 (UTC)
- Made an attempt to tighten up the wording and respond to your issues. See what you think. Mathglot (talk) 01:23, 25 February 2024 (UTC)
- The basic problems are still there. "Unsupported" is as ambiguous as "forbidden". Unsupported typically means someone won't help you do it -- it might work, but you're on your own. You get no support. Recursion just plain doesn't work -- you can't do it, so why don't we just say that? And it isn't true that whether a template call works or not depends on whether it is called for the purpose of documentation. The distinction is that it works when the template is displayed, but not when the template is expanded.
- If you want to keep it brief, then just don't mention documentation as an application of a template calling itself at all. The page explains elsewhere the difference between expanding and displaying a template and the concept of displaying a template to see documentation. Bryan Henderson (giraffedata) (talk) 04:21, 25 February 2024 (UTC)
- I see what the problem is now. The term unsupported in the world of a software feature is an ambiguous term, and can either mean what you inferred regarding no customer service, but just as often means the software is not capable of it:
- Currently, MyEclipse Blue Edition is available for Windows and Linux, though Mac is unsupported.[1]
- applications are single-threaded; multithreading in Trusty userspace currently is unsupported[2]
- Development using either HTML5 or WinJS is unsupported on Windows Phone 8.[3]
- As the symbol is unsupported by Ceefax/Teletext, a number sign - which resembles a musical sharp - is substituted.[4]
- This setting is not used by all platforms; changing its value is unsupported.[5]
- I used unsupported in that sense, but I'll try to find different wording. The phrase does not work is out, because like a car that does not work, it implies that something is wrong with it that need repair—that is not the case here, as it is working as designed. Mathglot (talk) 23:25, 25 February 2024 (UTC)
- Changed it to:
- Template recursion is not available; that is, a template may not call itself directly, or indirectly by calling other templates which call it. Attempts to do so will result in an error message describing a "template loop".
- Mathglot (talk) 23:30, 25 February 2024 (UTC)
- Thank you. And I agree about the problem with "does not work".
- On the matter of "support", you're absolutely right that it is often used exactly the way you used it, in addition to many other ways. I change "support" almost everywhere I see it in a technical context in Wikipedia both because of its ambiguity and the fact that there is always a plainer way to say whatever it's supposed to say. I think "support" is one of those things people say because it sounds smarter. Fundamentally, support means to hold up; metaphorically, it means to assist. When I read "the website supports JPEG", I wonder, "Does JPEG need this website's support?". Bryan Henderson (giraffedata) (talk) 20:01, 26 February 2024 (UTC)
- I see what the problem is now. The term unsupported in the world of a software feature is an ambiguous term, and can either mean what you inferred regarding no customer service, but just as often means the software is not capable of it:
- Made an attempt to tighten up the wording and respond to your issues. See what you think. Mathglot (talk) 01:23, 25 February 2024 (UTC)
Nesting template
in the nesting templates section under creating templates, in the second example, shouldn't it have a '3' in the line of code for template A, instead of a '1'? Or am I missing something? JoeJShmo💌 08:00, 19 July 2024 (UTC)
- Yes, it should by 3. I've fixed it. Bryan Henderson (giraffedata) (talk) 17:00, 19 July 2024 (UTC)