Help talk:Template/Archive 4

Latest comment: 7 years ago by Marchjuly in topic Non-free image use
Archive 1Archive 2Archive 3Archive 4Archive 5

Should there be a fourth transclusion tag?

Transclusion tags
Tag Suppression applies to Suppression applies on
noinclude text inside the tag the page containing the transclusion
includeonly text inside the tag the page containing the original content
onlyinclude text outside the tag the page containing the transclusion
? text outside the tag the page containing the original content

Dogmaticeclectic (talk) 11:02, 5 December 2013 (UTC)

So what you're suggesting is that if a template contained markup like
Text that should be included but not displayed on the template page. <the-fourth-tag>Some text that is always visible.</the-fourth-tag> More text that should be included but not displayed on the template page.
it would show on the template page as
Some text that is always visible.
and it would be transcluded as if it were
Text that should be included but not displayed on the template page. Some text that is always visible. More text that should be included but not displayed on the template page.
I don't think such a tag exists, but you can achieve a similar effect with two pairs of <includeonly>...</includeonly>. --Redrose64 (talk) 13:21, 5 December 2013 (UTC)
Precisely... except that, given the title of this section, it should be obvious that I already know it doesn't exist - right now, at least. What I'm asking is whether such a tag should perhaps be introduced. As for the last statement you wrote above, that is also the case with "onlyinclude", which can be replaced with two applications of "noinclude"... yet "onlyinclude" still exists. Dogmaticeclectic (talk) 13:29, 5 December 2013 (UTC)

asking for tech review

Could someone please review a template I've designed in case it has a technical issue? I don't think I have any coding left to do unless I have an error and I haven't designed a template from ground up before, so I'd like to be sure. I have tested it. It's User:Nick Levinson/Subscription or libraries and the latest tests are at my sandbox. I still have to finalize the documentation and create the categories the template will generate (the template draft now uses test categories X1 and X2), but all that in draft form is already at my sandbox (scroll down). I didn't find any other page for looking at a draft template. Thank you. Nick Levinson (talk) 21:30, 26 October 2013 (UTC)

looks good to me. I made some minor changes (hope you don't mind), but nothing was technically wrong with it. Frietjes (talk) 14:17, 27 October 2013 (UTC)
Thanks to both editors.
The excessive linking to the word after a URL was a past problem that was solved, then unsolved in this review, then solved again. There's technical detail about the cause available.
A new peculiarity arose: When the "via" parameter was used with text or a domain that is not a URL (it lacks the leading protocol), the template draft bracketed and repeated the non-URL, but when an HTTP URL was supplied it did neither. An HTTP URL with text displayed as text, one URL, and the text again. One or two other confusing manifestations also displayed. While the coding showed brackets and a repeated triple-braced code, I don't understand why the effect did not occur with all values. Given the current and past effects, I don't understand the need for the doubling or the brackets and I took them out, but would like to know their utility and if I should restore them.
In the display, the space between the en-dash and the word "via" disappeared. That would be stylistically consistent with the MOS for an em-dash but not for an en-dash, which in this case is preceded by a space. Since the coding showed whitespace (I assume a soft space), I replaced it with a nonbreaking space.
Then I discovered that if the "via" parameter is not used a double space appears, instead of a single, at the beginning, so I moved a new space from between the #if and #switch parameters and into the end of the #if parameter. That led to nonspacing between displayed strings (apparently it gets stripped out), and I don't want to try the HTML code for a nonbreaking space in case that gets interpreted as part of a preceding linkable URL, so I replaced that newly-moved soft space with a Spaces template for one space.
Thank you for the review. I'll see if there's anything else here soon and then, maybe in a week, I'll finish up.
Nick Levinson (talk) 19:36, 27 October 2013 (UTC)
In my last post, I meant "#if and #switch functions and into the end of the #if function", not such parameters. Nick Levinson (talk) 22:41, 30 November 2013 (UTC) (Corrected misspelling & reworded: 22:44, 30 November 2013 (UTC))
Done (actually, a while ago). Thanks again. Nick Levinson (talk) 01:34, 13 December 2013 (UTC)

Can't get addition to template to work

The template Wikiversity:Template:Peer reviewed has been working fine before, but today I tried to add a new {{{2}}} feature that should be filled with an URL to an old revision of the article. An example of this template is displayed at the top of the article Wikiversity:An epidemiology-based and a likelihood ratio-based method of differential diagnosis. The {{{2}}} should be included after the statement "A permament link to peer reviewed revision is located at", but it doesn't show up. Also, I had to add two vertical bars afterwards, that is ||, in order to prevent the entry given in {{{3}}} to show up after "located at". Thus, it seems the whole space between those vertical bars meant to serve the {{{2}}}-purpose are just ignored, as if there was no space there at all. What can I do about it? Mikael Häggström (talk) 11:28, 12 February 2014 (UTC)

With these edits, you have repurposed the second positional parameter, which is not a good idea unless you are prepared to go through all pages transcluding the template to adjust the parameter values that they pass in. I see that you have tried to do that with these edits, but by using a double pipe you have moved the parameter whose value is [[Talk:An_epidemiology-based_and_a_likelihood_ratio-based_method_of_differential_diagnosis|Talk page]]. from second to fourth position. --Redrose64 (talk) 12:23, 12 February 2014 (UTC)
The fourth parameter (saying "Comments on the peer review statement are located at Talk page") is actually displaying correctly, except for the fact that I had to move it to the forth position with that double pipe to make it display correctly (it should have been in the third position. The problem is in displaying the permanent link at position 2. As said, it seems it is just ignored, and the system jumps directly to the next position (which is empty). Mikael Häggström (talk) 16:33, 12 February 2014 (UTC)
Solved it! I replaced the = signs with &#61; (link to edit). Still, thanks for your reply. Mikael Häggström (talk) 16:35, 12 February 2014 (UTC)

Making it easier?

Is there any way I can format the template so that the = sign doesn't have to be replaced with &#61; (or {{=}}) every time an URL is pasted into this field? Mikael Häggström (talk) 08:03, 13 February 2014 (UTC)

There are two ways. The most flexible, and the most intuitive, is to use named parameters - instead of coding the template for {{{1|}}} {{{2|}}} {{{3|}}} you could use something like {{{statement|}}} {{{permalink|}}} {{{comments|}}} which would allow the following usage:
{{Peer reviewed |statement=https://commons.wikimedia.org/wiki/File:Peer_review_statement_for_differential_diagnosis_article_2014.pdf |permalink=https://en.wikiversity.org/w/index.php?title=An_epidemiology-based_and_a_likelihood_ratio-based_method_of_differential_diagnosis&oldid=1135155 |comments=[[Talk:An_epidemiology-based_and_a_likelihood_ratio-based_method_of_differential_diagnosis|Talk page]]. }}
The other way is to leave the template alone, and instead the parameters can be explicitly numbered:
{{Peer reviewed |https://commons.wikimedia.org/wiki/File:Peer_review_statement_for_differential_diagnosis_article_2014.pdf|2=https://en.wikiversity.org/w/index.php?title=An_epidemiology-based_and_a_likelihood_ratio-based_method_of_differential_diagnosis&oldid=1135155 |3=[[Talk:An_epidemiology-based_and_a_likelihood_ratio-based_method_of_differential_diagnosis|Talk page]]. }}
unfortunately, if you number any one parameter, then you also need to number all of the parameters after that point. Notice how the third parameter is given |3= here - it wouldn't work if that were left off. --Redrose64 (talk) 15:23, 13 February 2014 (UTC)
Thank you very much   Mikael Häggström (talk) 20:11, 13 February 2014 (UTC)

Love templates and design? :)

We have a paid wiki-design contract position with the Wikimedia Foundation: We need your help making it easier for Wikimedians to participate in the movement and with each other!

  • Travel and Participation Support Grants is looking for someone to help design and build a new portal on meta-wiki to make this grants program easier to navigate and more fun to use. You'd be working with me, to make something suitable for this program that fits with other grants pages on meta-wiki. We’d prefer someone with wiki and template knowledge (this would outweigh other experience). Please see the job description for details, pass it along to anyone you know, and feel free to ask me or Siko if you have any questions. We look forward to speaking with you!
(We’re posting around the community because we’d love to hire a Wikipedian and thought some people here might be interested - if you apply, please include some info about your Wikimedia experience!)
heather walls (talk) 23:30, 19 February 2014 (UTC)

Onlyinclude help

On List of high schools in Orange County, California there is an onlyinclude command. I've tried moving it around and such but as it is transcluded on List of high schools in California the onlyinclude is visible on the mainspace. This is beyond me, I don't know how to hide the wiki command. Trackinfo (talk) 22:41, 22 February 2014 (UTC)

The <onlyinclude> - which is just above the heading "Public schools" - is present because the page is transcluded to List of high schools in California. It prevents the lead section (one hatnote and one paragraph) from being transcluded as well. However, there is a potential problem in that there is no matching </onlyinclude> and so transclusion finishes at the end of the page - with the result that the {{DEFAULTSORT:}} and categories end up on List of high schools in California as well, which is probably not a good idea. --Redrose64 (talk) 00:05, 23 February 2014 (UTC)
I made this edit which has fixed the problem. You might want to adjust some of the header levels at List of high schools in Orange County, California down by one: the level 2 headers at List of high schools in California are one per county, not one per school type within a county. --Redrose64 (talk) 00:12, 23 February 2014 (UTC)

'looking forward'

Could someone give me a simple example of how a parameter can 'look forward' to another? I'd like to automate {{IPAc-ja}} so that if you enter 'n' as a value, the output will depend on the following parameter (n before t or d, m before p or b, ŋ before k or g, etc). Currently this has to be done manually, and the fact that Wiktionary nearly always gets it wrong suggests that is not a good idea. — kwami (talk) 22:20, 11 March 2014 (UTC)

{{IPAc-ja}} passes the characters one at a time to {{c-ja}} so you would have to also pass the next character each time. For example, {{#if:{{{3|}}}|{{c-ja|{{{3}}}}}}} could be changed to {{#if:{{{3|}}}|{{c-ja|{{{3}}}|{{{4|}}}}}}}. {{c-ja}} would then need code to test {{{2}}} for some values of {{{1}}}. This assumes that only the following and not the preceding character matters, i.e. if you have n|t then the code for n can depend on t, but the code for t cannot depend on n. PrimeHunter (talk) 23:56, 11 March 2014 (UTC)
Thanks. Any idea what I'm doing wrong here[1][2]? — kwami (talk) 01:35, 12 March 2014 (UTC)
What is #sub supposed to do? I haven't seen that before and it doesn't appear to be defined. Is there a reason to not just say ja{{{1}}}{{{2|}}}? PrimeHunter (talk) 01:57, 12 March 2014 (UTC)
#sub is described here. It would take much longer to give all possible combinations of two parameters. The #sub command is supposed to strip the second down to just the first letter, which is the only relevant bit. — kwami (talk) 02:02, 12 March 2014 (UTC)
That extension is not listed at Special:Version so it's not installed here (that was controversial for years until we got Lua). You can use {{Str left}}. PrimeHunter (talk) 02:11, 12 March 2014 (UTC)
That works perfectly! Thanks! — kwami (talk) 02:50, 12 March 2014 (UTC)
Good. If {{{2}}} is undefined then it simply produces those 7 characters, so {{Str left|{{{2}}}|1}} produces {. {{Str left|{{{2|}}}|1}} would produce empty. Maybe this doesn't matter in your templates. PrimeHunter (talk) 03:12, 12 March 2014 (UTC)
Better fix it to be sure. Thanks. (It doesn't seem to have been a problem, but I don't know why. It should've been.) — kwami (talk) 03:15, 12 March 2014 (UTC)

how can I test for unsupported parameters?

Transclusions of complex templates like {{infobox language}} tend to accumulate unsupported parameters, added by people unfamiliar with the template. Some of these should be corrected, and some just deleted. Is there a way to test for such things? I coded that template to generate an error if certain specific parameter names are used, but that only catches ones I've noticed in the past. Is there a way to do this for any unsupported param? — kwami (talk) 22:14, 10 March 2014 (UTC)

Unused parameters just get dumped by the system, there is no way to catch them unless you know beforehand what parameters are being added that shouldn't be... This can be complicated by different casing and the choice of whether to use spaces or underscores. The only thing that I can think of that "could" be done would be to run a bot (or use AWB) to go through all transclusions of the template and replace the template calls with new calls searching for a regular expression without case sensitivity to replace all of the known parameters and variations with the proper parameter names and dumping the rest out. This could be a very tedious process, especially on highly transcluded templates, and I don't see it as being a net gain in most cases myself (unless you are running through all of the transclusions to fix a superseded parameter anyways). Just my thoughts... — {{U|Technical 13}} (tec) 22:23, 10 March 2014 (UTC)
pretty easy to do with WP:LUA, all you need is a list of the valid parameters, and it can tell you if one is being used that is not on the list. Frietjes (talk) 22:26, 10 March 2014 (UTC)
Regular Wikicode can't test for unrecognised parameters; all we can do is test for commonly-made errors. For example, if a page is about a steam locomotive, it probably has {{Infobox locomotive}}; and if we wish to show the weight of the loco (or its tender) in the infobox, several parameters are available: we might use |weightondrivers=80 tons |locoweight=80 tons |tenderweight=80 tons or |locotenderweight=80 tons depending on what the 80 tons specifically applies to. If we use the somewhat vague |weight=80 tons this would put the page into Category:Unusual parameters of Infobox locomotive template; but if we use e.g. |totalweight=80 tons this would do nothing. To do something if |totalweight=80 tons, the template would need to explicitly test for that - and would still not pick up |weightofloco=80 tons - or any other variant.
As Frietjes notes, writing a template in Lua can detect unrecognised parameters, and many of the citation templates like {{cite book}} will do just that: {{cite book|title=A Book|totallybogus=Hello World}}A Book. {{cite book}}: Unknown parameter |totallybogus= ignored (help) --Redrose64 (talk) 22:59, 10 March 2014 (UTC)
Thanks. So I'd need to learn Lua, or have s.o. rewrite the template. Probably not worthwhile. We had a bot run a couple years ago, but usually this kind of thing is considered too trivial to get bot approval for. Thanks anyway. — kwami (talk) 00:10, 11 March 2014 (UTC)
a bot run is probably your lowest cost option, I would suggest asking Plastikspork. His/her bot was used to scan transclusions of Infobox power station (see this thread). by the way, you don't need to rewrite the infobox just to add some tracking (as I am sure you have noticed). I can create a general purpose module for detecting bogus parameters if there is interest. it would be under 25 lines in LUA. I might do it tomorrow if I have some time. Frietjes (talk) 00:30, 11 March 2014 (UTC)
Would it be possible to have it generate a category or something, so there's a centralized report? — kwami (talk) 00:51, 11 March 2014 (UTC)
{{infobox language}} invokes {{infobox}} which invokes Module:Infobox, so the core is Lua. I suggest asking this question at Template talk:Infobox. --  Gadget850 talk 01:09, 11 March 2014 (UTC)
Okay, thanks. I asked there and pinged Frietjes. — kwami (talk) 19:10, 11 March 2014 (UTC)
for anyone who is interested, this is now implemented as Module:Check for unknown parameters, and appears to be working. It's 26 lines of LUA (without comments or blank lines), instead of the predicted under 25 :) Frietjes (talk) 19:02, 24 March 2014 (UTC)

Asking for review

I have created a template in a sandbox that combines the Template:Archive box and the Template:Search archives in one template. Could someone please review the template? Perhaps someone can help me with the layout. Thanks! Template:Archive with search/sandbox Note: Links to archives and the search function are only shown if there is an actual archived section. --Fluffystar (talk) 16:35, 24 April 2014 (UTC)

Help with a template?

I was trying to make a footer template to go at the bottom of several films that Adam Gierasch directed. So far I have the films that he's directed but he also co-wrote a number of films with his wife Jace Anderson. I may re-do the template to encompass both of these, but I may do a separate one because I don't want to make the template too bulky- nor do I want to minimize Jace Anderson's contributions to the scripts. Gierasch himself says that he'll donate ideas and basic outlines, but she does all of the actual writing. Because of that, I don't want to have just "Adam Gierasch" at the top and then as such minimize her as a result. But then, listing both of them and then putting "films directed by ____" in the side might be bulky. In any case, the real reason I'm asking for help is that at the left hand side where it should have VTE it just says "error:page does not exist". I thought maybe it was a userspace thing, but it did it in the mainspace as well. I've created templates like this before, so I'm not sure what I'm doing wrong. I figured I should ask for help rather than leave a malformed box in the mainspace. You can find the template at User:Tokyogirl79/Adam Gierasch. Tokyogirl79 (。◕‿◕。) 13:51, 1 May 2014 (UTC)

The name parameter of a navbox is used to make the V T E links and must be the page name, in this case name = User:Tokyogirl79/Adam Gierasch. Change the parameter if the template is moved. PrimeHunter (talk) 14:23, 1 May 2014 (UTC)
(edit conflict) @Tokyogirl79: User:Tokyogirl79/Adam Gierasch is a navbox, and to get the v-t-e links to work, you need to set the |name= parameter to be exactly the same as the page name. So in this case you would use |name=User:Tokyogirl79/Adam Gierasch and if the page were later moved to Template:Adam Gierasch you would alter it to |name=Template:Adam Gierasch - or even |name=Adam Gierasch because the Template: part is unnecessary. --Redrose64 (talk) 14:27, 1 May 2014 (UTC)

Sanitize template input

Is there a method for sanitizing template input? For example, I'd like to remove apostrophes so as to have ''Saints Row 2'' (mobile) sanitize to Saints Row 2 (mobile). Thanks czar  20:12, 18 May 2014 (UTC)

You could put the parameter value through {{replace}}. Single apostrophes are often legit, as in O'Hara, so those need to be left alone; thus, you would need to use {{replace}} twice:
{{replace|{{replace|{{{parameter}}}|'''|}}|''|}}
The first (inner) pass would replace all instances of three consecutive apostrophes with the null string, the second (outer) pass would replace all instances of two consecutive apostrophes with the null string. --Redrose64 (talk) 20:27, 18 May 2014 (UTC)

Template that can detect being inside of an archived discussion

Is there a method for a template to detect whether it's inside a discussion that has been archived? Say a template within a discussion that would change when between {{Archive top}} and its bottom? Couldn't find anything in search czar  04:56, 24 May 2014 (UTC)

Technically, yes: but not solely with a template, we'd need to add something to the site CSS as well. What I'm thinking is that we define a new class - say changeifarchived - which behaves differently according to whether it's enclosed by {{archive top}} or not; it would make use of any class that is used by {{archive top}}. At present, {{archive top}} wraps the thread in <div class="boilerplate"> so we could make use of that; the downside is that the boilerplate class is used in other places for non-archival purposes. It might be best to also add a second class to {{archive top}}, say class="boilerplate archivedthread", and then we can set up the CSS rules
.changeifarchived {
  border: 1px solid blue;
}
div.archivedthread .changeifarchived {
  border: 3px dotted red;
}
Then we make sure that our template wraps its content in the new changeifarchived class - it doesn't matter if it uses <div>...</div> <span>...</span> or another element. Let's assume that we have a template called {{different if archived}} coded as
<span class="changeifarchived">{{{1}}}</span>
and we use it like this
{{archive top}}
Some archived text {{different if archived|with a template}} inside it.
{{archive bottom}}
:Some non-archived text {{different if archived|with a template}} inside it.
The effect would be like this:

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


Some archived text with a template inside it.

The discussion above is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Some non-archived text with a template inside it.
This isn't a working demonstration - I didn't set up any classes or templates. The border patterns are just examples. --Redrose64 (talk) 10:32, 24 May 2014 (UTC)
@Redrose64, would this require that the CSS rules be set in advance? It would be preferable to be able to style the change within the template (because a dotted border may not be the intended change across templates). It there any way to do this now with a template detecting that it's within a "boilerplate" class without going back to the sitewide CSS rules? czar  14:10, 24 May 2014 (UTC)
Unless I'm completely misunderstanding the request, this can most certainly be done with just templateFu. I'll take a better look in about 10 hours from my computer when I get home. — {{U|Technical 13}} (tec) 14:33, 24 May 2014 (UTC)
@Czar: There are two ways of applying styling. One is by placing inline styling into the style="" attribute of an HTML element, as in
<span style="border: 3px dotted red;">some styled text</span>
- these cannot be applied conditionally, and so there is no way for the border to be automatically coloured differently according to what surrounds that <span>...</span> element. The other way is by using style sheets - the CSS files - which are applied to the element by various means known as selectors. Selectors can get complicated, but they can pinpoint particular elements on a page according to criteria like "if an element of type x is inside another element of type y, style it this way, otherwise style it that way". Class selectors are perhaps the easiest to understand - in my first boxed example above, the first line begins .changeifarchived - this means "any element that has the changeifarchived class should be styled this way". The fourth line begins div.archivedthread .changeifarchived - this means "any element that has the changeifarchived class, and which is also enclosed by a <div>...</div> element that has the archivedthread class, should be styled this way"; it uses the descendant combinator to specify this.
When you write templates that style the text, they can use either the style method or the class method; but to utilise the class method, the classes concerned need to be defined in a CSS file. Since we can't set these up on a per-page or per-template basis, they would need to go into the site CSS. See for example the request at MediaWiki talk:Common.css#Glossary classes. --Redrose64 (talk) 14:38, 24 May 2014 (UTC)
Thanks for the write-up. I'm already familiar with how CSS works. I wanted to use this not to style a section differently when inside a boilerplate/changedifarchived class (though that can be useful for other reasons), but to automatically remove a category (as added through a template) when the section has been archived. czar  15:02, 24 May 2014 (UTC)
I'm pretty sure that it's not possible, since open WP:AFD debates have a {{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD}}, the sole purpose of which is to add two categories (like Category:AfD debates (Not yet sorted) and Category:AfD debates) which needs to be manually removed when the AFD is closed. --Redrose64 (talk) 15:10, 24 May 2014 (UTC)
Okay. Part of me asking was to see whether that could be helped (and, you know, it would be useful for other reasons) czar  15:13, 24 May 2014 (UTC)
  • From what I can read on my phone, what you want is possible inside of a template although it is not instantaneous as it requires waiting for the job queue to keep it updated and sometimes requires a null edit of which there are bots for. — {{U|Technical 13}} (tec) 15:30, 24 May 2014 (UTC)
@Technical 13, I'd be interested in reading more about this if you can send me a link when you get to a computer. Thanks for your help, all czar  15:39, 24 May 2014 (UTC)
  • Ahh.. okay, now I can read it better. When you say archived, you just mean closed to future discussion, and not actually archived on the archive page. I do believe that can be done with Lua, it can also be done with css as Rose suggests in cooperation of a template, or it could be done via JavaScript. "If" you had meant what I thought you did of it actually being archived on an archive page, then the template could read the pagename, check to see if "archive" was included in the title, and style or change the categories with parser functions. — {{U|Technical 13}} (tec) 21:47, 24 May 2014 (UTC)

Lang-eu

There seems to be a display problem specific to the Basque-language version of {{Lang}}. At Asno de las Encartaciones I wanted the opening of the lead sentence to read "The Asno de las Encartaciones, Basque: Enkarterriko asto, is ..." (which of course I could do by writing it in that way, without using the template at all). But using {{lang-eu}} produces this result: "The Asno de las Encartaciones', Basque: Enkarterriko asto', is ...". Changing the language to, say, Spanish, (i.e., changing the letter u of eu to an s without making any other change) causes it to display as expected. Can anyone see what the problem might be (most likely is user error, of course); or even fix it? Thanks, Justlettersandnumbers (talk) 11:23, 9 July 2014 (UTC)

@Justlettersandnumbers: My second attempt seems to have worked, but I have no idea why {{lang-eu}} and {{lang-es}} behave differently. -- John of Reading (talk) 12:19, 9 July 2014 (UTC)
Yes, your fix is good (I thought I'd tried that, but obviously not); but it doesn't solve the underlying problem, which as far as I know is limited to this one variety of {{Lang}} (of course, I haven't actually gone through the other 200? 300? to check), and I think needs looking at. Justlettersandnumbers (talk) 13:33, 9 July 2014 (UTC)
This edit is the proper fix. --Redrose64 (talk) 15:23, 9 July 2014 (UTC)
Ha! Obvious once it's been pointed out. -- John of Reading (talk) 16:29, 9 July 2014 (UTC)

How to variablize Category url

I'm having trouble creating a link to a Category page utilizing a variable string passed as a parameter: [[Category:{{{unit_class}}}]] How does one do this properly? 209.16.118.178 (talk) 15:01, 16 September 2014 (UTC)

If you mean placing the page in a category then [[Category:{{{unit_class}}}]] is correct syntax (it requires {{{unit_class}}} to have a value), and the problem must lie elsewhere if it doesn't work for you. If you mean creating an inline link at the place of the code then you must place a colon in front of the category name like [[:Category:{{{unit_class}}}]]. This is a general category feature unrelated to templates. For example, [[:Category:Wikipedia help]] produces Category:Wikipedia help without placing this talk page in the category. PrimeHunter (talk) 15:21, 16 September 2014 (UTC)
Thanks for your reply. An example is at http://gow-fireage.wikia.com/wiki/War_Elephants notice in the infobox, on the right, with the field labeled "Type"? You see it blank, which I dont'get, see the Template:Unit at http://gow-fireage.wikia.com/wiki/Template:Unit?action=edit Enorl76 (talk) 18:47, 16 September 2014 (UTC)
As mentioned, if you want to display an inline link to the category in the infobox then you must place a colon in front like [[:Category:...]]. If you both want to display the category link in the infobox and place the page in the category then you must do both: [[:Category:...]][[Category:...]]. Currently the template only says [[Category:...]]. That isn't supposed to display anything where the code is placed. It only places the article in the category and places a link to the category at the bottom of the article. All of this is basic category features and unrelated to templates and parameters. See Help:Category. PrimeHunter (talk) 22:58, 16 September 2014 (UTC)

Template:Infobox election

Earlier today this template began appearing malformed on articles (e.g. Next United Kingdom general election, German federal election, 2013). The template itself has not been edited since December last year, so I assume an underlying template has been broken. Can anyone help out? Please comment at Template talk:Infobox election. Cheers, Number 57 10:58, 6 October 2014 (UTC)

This has been resolved. -- John of Reading (talk) 11:33, 6 October 2014 (UTC)

Good faith confusion about includeonly

@Redrose64: Umm you've got a point. https://en.wikipedia.org/w/index.php?title=Help%3ATemplate&diff=633884924&oldid=633884024 Apologies. I will correct this on the transclusion page. --Mrjulesd (talk) 01:37, 15 November 2014 (UTC)

Templates showing

All templates seem to be collapsed right now? WikiOriginal-9 (talk) 21:15, 12 December 2014 (UTC)

I'm not seeing this. Looking through your recent contributions for clues, I found and fixed an error in the Going postal article - was that the problem you were referring to? -- John of Reading (talk) 22:12, 12 December 2014 (UTC)
All the navboxes I come across are all expanded (fully visible) - (I didn't mean to say collapsed earlier) and the show button is missing. WikiOriginal-9 (talk) 22:22, 12 December 2014 (UTC)
I'm not seeing that either. Do you have JavaScript turned off in your browser? [I'm about to go offline, BTW]. -- John of Reading (talk) 22:37, 12 December 2014 (UTC)
Thanks, it's fine now. I had it on though, so idk. WikiOriginal-9 (talk) 22:47, 12 December 2014 (UTC)

Help creating a template for Encylcopedia Virginia listings

I have a quick question: would it be possible to create a template for Encyclopedia Virginia articles akin to how we have templates for listings at IMDb or Find-A-Grave? (IE, like this: {{IMDb title| xxxxx }}) The reason I'm asking is that there are a lot of articles at EV that have articles on here and it'd be a valid external link for these articles since the EV would be able to have links to various multimedia and whatnot that might not be available on Wikipedia. Plus they can go into more minutae than we can on here and it's a reliable source (vetted and all) so it'd be a useful external link. (If you're curious, here's a link to the entry for St. George Tucker to show what I mean by multimedia and such.) I can do without it, but I've never created anything of this nature before and it'd just be something nice to have. (Full disclosure, I'm Tokyogirl79 editing under a different name for my volunteer position at the Library of Virginia.) Tokyogirl79LVA (talk) 16:37, 4 March 2015 (UTC)

Looking for a counting template

I make regular edits to a page on Wikipedia, which includes a table, and a count of the number of rows in that table. It is common for someone to add/remove a row in the table without updating the manual count. I've developed a template that keeps a count of how often it is transcluded on the page, but I wanted to know if one already existed. What would be a good name for it ("count" is already in use)? -- Jevanyn talk 20:05, 15 April 2015 (UTC)

Jevanyn, where is the template? Frietjes (talk) 13:41, 25 April 2015 (UTC)
On another wiki. The main use case is on Wikipedia, though, on the List of oldest living people. There is a table of names that many users add/remove records in, but the text specifies how many men and women are listed, which frequently gets out of sync. I wanted to replace the "F" and "M" with ((count|F)) and ((count|M)), and put the counted totals in the text after the table. My question here was primarily what to call the templates so that they can be easily found and reused. -- Jevanyn talk 20:36, 27 April 2015 (UTC)
What is the code of the template? I wonder whether it uses a feature Wikipedia doesn't have, or does something which is too inefficient or impractical. PrimeHunter (talk) 21:07, 27 April 2015 (UTC)

If then else

Can anybody explain how to set the function of a parameters as either Yes or No. And that does a specific task when set yes and another specific task when said no? And how to set the default as yes?
aGastya  ✉ Dicere Aliquid :) 15:08, 29 April 2015 (UTC)

@Acagastya: Not sure what you mean, but we do have {{yesno}} --Redrose64 (talk) 16:46, 29 April 2015 (UTC)
@Redrose64:Okay Let me use it. If any problem, I will ask.
aGastya  ✉ Dicere Aliquid :) 17:04, 29 April 2015 (UTC)

Re-sectioned material

Recently we've been communicating through edit summaries. Please see them. But I must now try to put to rest any concerns about what's going on.

Section Syntax was short, like a man page, which I liked, but found lacking in what I considered critical syntax. That's how it started. After adding the missing syntax, I studied the entire page carefully. I noticed the "missing" information in a long bullet list. I also noting a main section Creating and editing. I then noticed a second bullet list, and a section titled Other details, all three exhibiting a mixture of Template Usage and Template Creating. So I took the three and distributed their content best I could between Using templates and Creating and editing templates. This grew the little Syntax section.

Syntax was renamed Using templates, and other sections had all their content moved all over the page, or were renamed or newly added. That made this page into a draft quality page. I feel it is a fine reorganization, but that it entails going through section by section to copy edit and integrate content that was more or less cut and paste there. — CpiralCpiral 23:58, 28 July 2015 (UTC)

@Cpiral: I worry that your edits have made the page harder to understand for people new to templates on Wikipedia. This page should be as simple as possible to help people understand the concepts involved - diving into complicated examples and terminology straight away is going to confuse people. If anything, the page needs to be simpler than it was before. — Mr. Stradivarius ♪ talk ♪ 04:49, 29 July 2015 (UTC)
I'd like nothing more than the honor of meeting your simplicity and introductory-level requirements. It saddens me to have to ruffle feathers of those whose names I've grown to respect.
I'm fairly new to template editing, and have fresh memories of how things seemed on the way up. Please give me a few days to get this page in shape. If you have any doubts, most of Help:Searching and Help:Pagename and WP:Pagename are my old works, {{val}} is recent, but {{tlusage}} and {{regex}} and {{search link}}are still in draft mode (until I get Help:Searching/Draft to share their new CirrusSearch parts).
Please let me worry for you for a little while. Thank you for your feedback. — CpiralCpiral 05:40, 29 July 2015 (UTC)
If you are fairly new to template editing, that really does suggest that you are perhaps not the best person to rewrite the help page. It should be written by those with a thorough understanding of how templates work (like me) but who also have experience in writing educational materials (not like me). If I, as an experienced template coder, have difficulty understanding your changes, how must a newbie feel? I notice that you reverted Mr. Stradivarius - this is not how WP:BRD works. You were bold in making your edits; Mr. Stradivarius (talk · contribs) reverted you, then we should get discussion - not further B/R. --Redrose64 (talk) 09:58, 29 July 2015 (UTC)
One plan might be to keep things fairly simple here, and move the advanced stuff to Wikipedia:Advanced template coding, and wiki-link if necessary. While the changes of Cpiral do make things more comprehensive they also make it more complex, and this complexity is perhaps better on another page. Templates are difficult for most, and need something simpler perhaps, at least to start with. --Jules (Mrjulesd) 11:45, 29 July 2015 (UTC)
(edit conflict) Well, I suppose I am a teacher in real life, so I probably fulfil the "writing educational materials" requirement. I also have a basic idea of how I think the page should go. But before we go about rewriting this, I wonder whether it might be better just to convert it into an index page. We already have mw:Help:Templates, which is quite well-written in my opinion, and there are several other template help pages around. Rather than having separate template help pages on several different wikis, how about just linking to one central one and making that one as good as possible? If there are things that only apply to this wiki we can add them to another help page here rather than clutter up the central page. — Mr. Stradivarius ♪ talk ♪ 11:49, 29 July 2015 (UTC)
I would like to restore the June 9 version of Help:Template. The Geek gradient dooms a proper Help page. — CpiralCpiral 20:16, 29 July 2015 (UTC)
I propose we put the current material at WP:Template. Wikipedia has a history of improving the Help namespace MediaWiki ships with. A thorough investigation of Wikipedia's history of moving the Help pages given by MediaWiki to more advanced Project versions should help assess my proposal. Transferring the history and attributions would require an import/export? — CpiralCpiral 20:16, 29 July 2015 (UTC)
The only bit of that which I understood was "I would like to restore the June 9 version of Help:Template", and I agree with the proposal. But if that is what you want, why did you revert Mr. Stradivarius? Their edit did restore the 9 June version. --Redrose64 (talk) 20:48, 29 July 2015 (UTC)
It has to do protocol, which I believe has to do with encouraging myself to edit. Thanks for the feedback, Redrose. I need some help in understanding it myself: In order to fork Help:Template to the new title Wikipedia:Template, as I propose, we'd need to delete the redirect WP:Template --> Help:Template, and then export Help:Template and then import it to WP:Template, all in order to preserve the history of contributions, right? — CpiralCpiral 21:58, 29 July 2015 (UTC)
I think that you're trying to complicate things unnecessarily. Just revert the whole page to how it was on 9 July, then leave it at that. --Redrose64 (talk) 23:01, 29 July 2015 (UTC)
Done already. — CpiralCpiral 23:35, 29 July 2015 (UTC)

Onlyinclude

If there is any onlyinclude tag, it should appear only once. Also there should be no includeonly or noinclude tags anywhere else. GeoffreyT2000 (talk) 16:30, 5 August 2015 (UTC)

Why only once? --Redrose64 (talk) 20:49, 5 August 2015 (UTC)
Ya can't go by the sounds of the names. "Yet another onlyinclude" is valid. Now, because these onlyincludes exclude what's outside of the them, while noincludes exclude what's inside them, when using multiple onlyinclude tags you don't need noincludes outside of them; however you need them inside to show "documentation only", and you need includeonly for the same reason inside of them, but to hide template code from that same documentation (when documenting from inside the template instead of using {{documentation}} exclusively.) It's a complete system with names that make make sense only in terms of the other names. — CpiralCpiral 22:21, 5 August 2015 (UTC)
You should get rid of the noinclude tags outside the onlyinclude tags, but not the text between them. Also, you should either get rid of both the includeonly tags outside the onlyinclude tags and the text between them, or replace <includeonly> with <!-- and </includeonly> with --> outside the onlyinclude tags. GeoffreyT2000 (talk) 22:44, 11 August 2015 (UTC)

HTML comments and noinclude/includeonly

Is <includeonly><!--</includeonly>text<includeonly>--></includeonly> equivalent to <noinclude>text</noinclude>? Similarly, is <noinclude><!--</noinclude>text<noinclude>--></noinclude> equivalent to <includeonly>text</includeonly>? GeoffreyT2000 (talk) 00:21, 12 August 2015 (UTC)

{{Identity}}

template:Identity, a utility template for template safety, is up for deletion -- 70.51.202.113 (talk) 05:29, 1 September 2015 (UTC)

Trying to make a Mars time template in my sandbox...

Link is here, with all info: User:MSJapan/Marstime.

Short version: I was asked for help to make a template to do a running clock for articles on Mars. Mars actually has timezones, but the offset from UTC is not a round number. Therefore, the end result should be from the now template, but adjusted for UTC - 2:02:21, and a different timezone listing. I therefore figured I had to adjust the currenttime template to address that, but it's not playing nicely with fractional offset. Can someone help? MSJapan (talk) 00:44, 4 September 2015 (UTC)

Error in the NIE template

The following mistake results in a widely propagated inaccuracy to an out-of-copyright citation at Wikipedia.If it can be fixed, the correction will propagate widely, and result in improved information accuracy in the encyclopedia.

The template:

This article incorporates text from a publication now in the public domainGilman, D. C.; Peck, H. T.; Colby, F. M., eds. (1905). New International Encyclopedia (1st ed.). New York: Dodd, Mead. {{cite encyclopedia}}: Missing or empty |title= (help)

should reflect the fact that the editors of this first edition were: Daniel Coit Gilman, Harry Thurston Peck, and Frank Moore Colby (see Template:New_International_Encyclopedia).

Instead, it presents the the third editor as "F. Moore" (presenting the middle name, omitting the surname).

Please, indicate here how this might be fixed (or, if easily done, execute the correction yourselves)? Cheers. Le Prof Leprof 7272 (talk) 16:18, 12 September 2015 (UTC)

@Leprof 7272: Have you taken this up at Template talk:NIE? --Redrose64 (talk) 20:20, 12 September 2015 (UTC)

Constructing a URL from template parameters

Following a change to a government web site, the Template:cite QPN needs to be updated. The main problem relates to the new URL format to be constructed from the two main parameters, a place name and a reference number. My current version in the Template:Cite QPN/sandbox works fine if the place name involved is a single word e.g. "Kenmore", but if it's a multiple word place name like "Kenmore Hills", it doesn't work. The URL I correctly generate for Kenmore is:

https://www.dnrm.qld.gov.au/qld/environment/land/place-names/search#/search=Kenmore&types=0&place=Kenmore41505

but for Kenmore Hills I need it to be:

https://www.dnrm.qld.gov.au/qld/environment/land/place-names/search#/search=Kenmore%20Hills&types=0&place=Kenmore_Hills48322

That is, in one place, I must replace the space between Kenmore and Hills with a %20 and in the other place with an underscore. How do I do that? (Note some place names might have 3 or more words separated by spaces).

I have tried using urlencode and replace but could not get them to work for me (I have never used them before). Thanks for any advice anyone can offer? Kerry (talk) 02:36, 13 September 2015 (UTC)

@Kerry Raymond: urlencode has a couple of options that you could try; see Help:Magic words#Paths - {{urlencode:Kenmore Hills|PATH}} -> Kenmore%20Hills and {{urlencode:Kenmore Hills|WIKI}} -> Kenmore_Hills. -- John of Reading (talk) 04:18, 13 September 2015 (UTC)

Onlyinclude in nowiki

On mw:Transclusion, it says Note that unlike <noinclude> and <includeonly>, <onlyinclude> will take precedence over enclosing <nowiki> tags. In other words, <nowiki><onlyinclude>My content</onlyinclude></nowiki> produces only "My content" when transcluded.. However, in fact this is not true – onlyinclude tags within nowiki tags are treated like any other text inside nowiki tags. GeoffreyT2000 (talk) 18:45, 29 September 2015 (UTC)

The quote from mw:Transclusion is about transclusion behaviour and is correct. Transclusion of User:PrimeHunter/sandbox3 produces:
{{User:PrimeHunter/sandbox3}} (example deactivated after sandbox has changed)
"Before" and "After" are not transcluded so <onlyinclude>...</onlyinclude> works inside <nowiki>...</nowiki>. On the page itself it's treated like other tags but not when it's transcluded. PrimeHunter (talk) 19:59, 29 September 2015 (UTC)

Bug introduced Thursday Nov 12 - Please fix immediately

I don't know where to post this: several different Infobox templatea don't render correctly for an hour. Sections in the article do not float the infobox anymore, and as a result, the layout is disrupted (white area between lead/TOC and following sections). {{Infobox settlement}} {{Infobox planet}}. This is only notable when the lead is short. Example e.g. Eastern Finland Province. This bug should affect thousands of articles, mostly stubs. Thx for reposting this notice to a more appropriate location so it can reach the "culprit" Rfassbind – talk 18:18, 12 November 2015 (UTC)

User:Rfassbind, see this thread. Frietjes (talk) 18:22, 12 November 2015 (UTC)

Is this the best place to ask for Wikimedia contributor assistance regarding templates?

Can someone suggest a better place to ask for help using and developing templates? Blue Rasberry (talk) 20:04, 30 November 2015 (UTC)

There is Wikipedia talk:WikiProject Templates, but I don't think this is a bad place to ask. WP:VPT is a good place to ask as well. — Mr. Stradivarius ♪ talk ♪ 02:08, 1 December 2015 (UTC)

Template redesign - want to make horizontal infobox

Wikipedians know that standard infoboxes are horizontal. I am working with this experimental infobox - {{Medical condition classification and resources}}. Here is a nice instance of it:

{{Medical condition classification and resources 
 | DiseasesDB      = 29031
 | ICD10           = {{ICD10|M|10||m|05}}
 | ICD9            = {{ICD9|274.00}} {{ICD9|274.1}} {{ICD9|274.8}} {{ICD9|274.9}}
 | ICDO            =
 | OMIM            = 138900
 | OMIM_mult       = {{OMIM2|300323}}
 | MedlinePlus     = 000422
 | eMedicineSubj   = emerg
 | eMedicineTopic  = 221
 | eMedicine_mult  = {{eMedicine2|med|924}} {{eMedicine2|med|1112}} {{eMedicine2|oph|506}} {{eMedicine2|orthoped|124}} {{eMedicine2|radio|313}}
 | MeshID          = D006073
}}

Here is how that renders -

I would like to use code as seen above to produce a horizontal version of the infobox. Here is a mockup (archived as version 1) -

The base template here, {{Medical condition classification and resources}}, is actually from {{infobox}}. I am not sure there is such a thing as a "horizontal infobox", but for example, {{Authority control}} seems to do this for example with Template:Authority_control#Examples. The idea for this horizontal version came from the Authority control box, and I want to copy that.

Does anyone know how I can make a horizontal infobox that looks like my mockup but which can be filled in with the code I present above? Blue Rasberry (talk) 20:14, 30 November 2015 (UTC)

@Bluerasberry: I've had a go at adding parameters to your mockup User:Bluerasberry/Medical condition classification and resources - horizontal test-2. You didn't say how you wanted the Patient UK parameter to be named, so I've left that out for now. — Mr. Stradivarius ♪ talk ♪ 23:44, 30 November 2015 (UTC)
Mr. Stradivarius You are more insightful and perceptive about templates than I am. I hardly know what I am doing when I manipulate them but now I see - yes, all of these have some relationship between the field and value, except for Patient UK which has an external link for its value. No, I do not know how the Patient UK parameter should be named. I need to think more about that. Blue Rasberry (talk) 22:01, 3 December 2015 (UTC)
I made different templates for the different versions. Here is how your change looks.
Thanks so much. Let me look... Blue Rasberry (talk) 17:10, 1 December 2015 (UTC)
{{User:Bluerasberry/Medical condition classification and resources - horizontal test-2
 | DiseasesDB      = 29031
 | ICD10           = {{ICD10|M|10||m|05}}
 | ICD9            = {{ICD9|274.00}} {{ICD9|274.1}} {{ICD9|274.8}} {{ICD9|274.9}}
 | ICDO            =
 | OMIM            = 138900
 | OMIM_mult       = {{OMIM2|300323}}
 | MedlinePlus     = 000422
 | eMedicineSubj   = emerg
 | eMedicineTopic  = 221
 | eMedicine_mult  = {{eMedicine2|med|924}} {{eMedicine2|med|1112}} {{eMedicine2|oph|506}} {{eMedicine2|orthoped|124}} {{eMedicine2|radio|313}}
 | MeshID          = D006073
||
}}

generates

Hmmm... Blue Rasberry (talk) 17:21, 1 December 2015 (UTC)

@Bluerasberry: So what do you want the Patient UK parameter to look like? |PatientUK=? |patient_uk=? Let me know and I'll add that as well. Also, do all of the links do what you expect? — Mr. Stradivarius ♪ talk ♪ 22:42, 1 December 2015 (UTC)
@Mr. Stradivarius: Thanks for helping me with this. Maybe you saw that I used it and mentioned you at Template_talk:Infobox_medical_condition#Another_reform_proposal_-_split_infobox_into_.22human_readable.22_and_.22non_human_readable.22_and_call_from_Wikidata. Already something has changed - I found {{Medical condition classification and resources}} and now I am reconsidering what you did. I would rather have these links in Wikidata and pull them from there rather just keep them locally on English Wikipedia. Some of these links and classification systems are already available in other languages. I would like to pause development of this template for now pending comment at "infobox medical condition" and the possibility of putting this information in Wikidata, then calling it back to English Wikipedia from there. Thanks a lot - I have hardly worked with templates and it is interesting to finally see how one works. Blue Rasberry (talk) 23:26, 1 December 2015 (UTC)
@Bluerasberry: How about using both local parameters and Wikidata? The template can be set up so that it uses the local parameter if it is available, and if it isn't, it uses data from Wikidata. And if there is no data on Wikidata for the link in question and no local parameter is specified, that link can be made not to display. — Mr. Stradivarius ♪ talk ♪ 05:37, 2 December 2015 (UTC)
Mr. Stradivarius I hardly know what is possible or easy but yes, setting these up to take a local parameter would give the option of a local override and be ideal. Without a local parameter, pulling data from Wikidata is best. I do not know where to begin with this. I checked - it seems that these and lots of other values are already in gout (Q133087).
Does that mean that these can already be connected to a template and called from Wikidata, to render the same output but not based on local input? Blue Rasberry (talk) 22:01, 3 December 2015 (UTC)
@Bluerasberry: That's right. You can get the data with, e.g., {{#property:p604|from=Q133087}}, or if you're on the Gout page already, just {{#property:p604}}. This produces "000422". Most of the properties produce multiple values, though (for example, {{#property:p493|from=Q133087}} produces ""), so we would need to use Lua in some way to format them properly. — Mr. Stradivarius ♪ talk ♪ 04:28, 4 December 2015 (UTC)

Template talk:Hdl#Error message

Could someone please take a look at the above error? Thanks. DrKay (talk) 16:19, 9 December 2015 (UTC)

Efficiency advice

I'm intending to create a template for easy citation of a stock set of sources, such that

  • {{grammar source|CMS16|p=37|chapter=Capitalization}}

or

  • {{grammar source|NHR2|pp=27–32|chapter=Full stop}}

will auto-generate a w:en:Template:Cite book citation with all the stock citation information (author/editors, publisher, publisher location, date, URL, ISBN, etc.) pre-filled, and do this for a long list of grammar and style sources that we need to frequently cite in WP articles on English language grammar and usage, like The Chicago Manual of Style 16th ed, or New Hart's Rules 2nd ed.., for these two examples.

What's the most efficient way to go about this, without having to resort to a Lua/Scribunto module? I'm not certain that the most obvious answer to an everyday template editor is the correct one, given the variety of technical considerations outlined at meta:Help:Advanced templates, some of which aren't easy to parse for someone not steeped in MediaWiki's internals.

I'm thinking that it needs a switch [perhaps in a subtemplate] that then calls a[nother] subtemplate to to populate the cite tags. Ideally, the list of sources and their details, given in a set order of parameter values, would be a separate transclude for easy expansion with low risk to accidentally doing something to the surrounding code.

In a very similar vein, I want to create a template called {{WP}} that will take any value like "WP:NPOV", check a list of known shortcuts, and wrap <abbr>...</abbr> around it with {{Abbr}}, with the expansion of the shortcut as the tooltip text ("Wikipedia:Neutral point of view"), and also be able to check a list of common #-anchor targets in major policy pages, and add those, too (e.g. if someone gives {{WP|NOT|SOAPBOX}}). The entire output would be styled with {{Smallcaps2}} to reduce the shouting effect of all-caps shortcuts. I would see about having a bot maintain the list of shortcuts, by tracking where every "WP:<string of uppercase characters>" redirect points to. As in the above case, it would be useful if this list were in a transcluded file.

 — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  06:38, 20 February 2016 (UTC)

You could have a look at {{RCTS-LocosGWR-8}} where the |edition= parameter varies the output:
  • le Fleming, H.M. (July 1953). White, D.E. (ed.). The Locomotives of the Great Western Railway, part eight: Modern Passenger Classes (1st ed.). Kenilworth: RCTS. ISBN 0-901115-19-3.
  • le Fleming, H.M. (November 1960) [1953]. White, D.E. (ed.). The Locomotives of the Great Western Railway, part eight: Modern Passenger Classes (2nd ed.). Kenilworth: RCTS.
or see {{Rolt-Red}} where the |year= value is fed through a {{#switch:}} - note that few of the possibilities are documented. I wouldn't try to make one universal template though, it won't handle all situations without redundancy. --Redrose64 (talk) 10:45, 20 February 2016 (UTC)
Thanks, but I already know how to do that stuff; what I'm trying to do here is feed a set of predetermined data, which varies with a "trigger", plus some variable data passed with the trigger, through a static template, and do so in a way that doesn't cause overhead problems (just the fact that it involves the citation templates poses an overhead risk; there are articles running into too-may-citations problems already because of the number of parser calls generated by overly-complex cite templates).  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  01:57, 22 February 2016 (UTC)
I think the closest thing that we have to what you want is Template:Flag et. al. and the country data templates. Template:Flag calls a different country data template depending on its first parameter, and the country data templates generate the output via a formatting template. In your case, Template:Grammar source could act like Template:Flag, and Template:Grammar source/CMS16 and Template:Grammary source/NHR2 could act like the country data templates. The formatting template would always be {{cite book}}, so the CMS16 and NHR2 subtemplates can just call it directly rather than having a parameter to tell them what template to call. (There's a more detailed explanation of the flag template system here.)

This would work well if the template users only have a small number of parameters which they might need to specify. If the number of parameters that users may need to specify becomes large then a Lua module may be a better choice, as otherwise you would have to pass through every possible parameter in Template:Grammar source and Template:Grammar source/CMS16, Template:Grammary source/NHR2, etc. Also, if you need to pass through an infinite number of parameters (e.g. author1, author2, ... authorn) then you have to use Lua, as in Lua you can pass through just what the user specifies, but you can't do that in normal template code. — Mr. Stradivarius ♪ talk ♪ 11:42, 20 February 2016 (UTC)

Ah, yes, the flag templates are a good mode;, they've been around long enough if they were an efficiency problem, someone would have fixed them. For this, there would normally be just the source name and the page number, maybe a chapter. The author info, etc., doesn't change. If it did, between editions, we'd add a new edition: NHR3, NHR4, etc. The "WP" template would also have a limited number of parameters.  — SMcCandlish ¢ ≽ʌⱷ҅ʌ≼  01:57, 22 February 2016 (UTC)
Well, various attempts have been made to convert the flag templates to Lua, e.g. Module:Flags and Module:CountryData, but none of them have stuck yet. I don't think the template versions are particularly inefficient, though. They just use three levels of nesting, none of the templates are particularly big, and they don't pass through that many parameters. It's difficult to say whether using Lua would bring a performance advantage over the template versions, especially after the performance increases in the MediaWiki code we've seen in the last year. — Mr. Stradivarius ♪ talk ♪ 02:20, 22 February 2016 (UTC)

Check if user is logged in

Is it possible to check whether a user is logged in? (I have a button in a template and I'd like it to function differently if the user is logged in.) czar 02:56, 29 February 2016 (UTC)

@Czar: It is indeed, but only if you are substituting. {{subst:#invoke:IPAddress|isIp|{{subst:REVISIONUSER}}}} takes the current user's username and gives "4" for IPv4 addresses, "6" for IPv6 addresses, and blank for logged-in users. It isn't possible to tell what user is viewing a transcluded template, however, as it would create problems for Wikipedia's caching system. — Mr. Stradivarius ♪ talk ♪ 03:19, 29 February 2016 (UTC)
So based on Help:Magic words#Other variables by type (There is no way to show the user viewing the page due to technical issues), I suppose we can't know/use the editor's IP status in advance of their edit. czar 05:48, 29 February 2016 (UTC)
That's right. The problem is that if you show different content for each user, then you have to generate the page dynamically each time it is viewed. This uses a lot more resources than what we do currently, which is to generate the page dynamically only for users that are logged in. We are only able to cope with Wikipedia's millions of daily page views because most of the time we are serving up static content, rather than dynamic content. — Mr. Stradivarius ♪ talk ♪ 06:33, 29 February 2016 (UTC)

Append to specific section

When attending an edit-a-thon, a new user's first edit is often signing into the event's page. {{meetupsig}} or {{Meetup participant signup}} is a jury-rigged way of doing this: user clicks "sign up" button, sees a few preloaded squiggles, clicks "save" and magic happens. (Is there a better way of doing this?) The main issue with how this is set up is that the appended text (a signature) is added at the bottom of the page rather than at the bottom of a specific section. Is it possible to configure inputbox such that text is appended at the top/bottom of a specific page section rather than at the top/bottom of the page? Thinking off-hand, I realize that the section in question could just be another page (then transcluded in the parent page's section)—this would be more disorienting for the editor, but would have the effect of appending to the end of a section. Any elegant answers to the main question? @Mr. Stradivarius? czar 03:44, 29 February 2016 (UTC)

It is possible to append it to a different page and transclude, but this involves extra moving parts (and would require purging to show on the page), that would complicate things if we added them right now. I don't think it is possible to directly append to the bottom of a specific section, but I would be glad to be corrected on that point.--Pharos (talk) 04:20, 29 February 2016 (UTC)
Yep, it's not currently possible to append to a specific section, only to the end of a page. — Mr. Stradivarius ♪ talk ♪ 06:38, 29 February 2016 (UTC)
Wikipedia:Village pump (technical)/Archive 143#Add line is related. --Redrose64 (talk) 17:29, 29 February 2016 (UTC)

Transcluding a template which normally adds a category, but without adding any category?

If an existing template is coded to put a category on pages, is there a way to transclude that template without any category being added to the page (without first modifying the template)? Could a wrapper template do this? (The purpose is for showing what a template looks like on a page where you don't want to add any category.) --Pipetricker (talk) 23:23, 16 May 2016 (UTC)

No. The template needs to be written in such a way that categorisation may be turned off, as with most WikiProject banners when |category=no is passed in. --Redrose64 (talk) 09:11, 17 May 2016 (UTC)
It's actually possible to remove the category with string processing of the template output. This uses {{Replace}} to remove [[Category:Project-Class redirect pages]] from the output of {{WikiProject Redirect}}:
{{replace|{{WikiProject Redirect}}|[[Category:Project-Class redirect pages]]|}}
The code here requires an exact string match including spaces, sort keys or whatever. Special:ExpandTemplates can reveal exactly what a template outputs. PrimeHunter (talk) 10:59, 17 May 2016 (UTC)
Nice! --Pipetricker (talk) 14:08, 17 May 2016 (UTC)

Using heading in a template

How do you use a heading with an “edit” button in a template?

If you use a heading, the “edit” button goes to the template page instead of the page on which it’s used, and if you use <includeonly></includeonly> tags, there’s no edit button!

Is there a way around this?

P.S. I don’t want to use the method of removing all the edit buttons in the headings in the article on which it’s used.
PapíDimmi (talk | contribs) 18:55, 19 July 2016 (UTC)

In what context are you trying to do this? --Redrose64 (talk) 20:15, 19 July 2016 (UTC)
I want a template to insert a heading when it is used. It will act as though it is a heading inserted to the page manually.
E.g., let’s say that the template goes something like this:
==Example heading==

Some stuff.
Let’s also say that the template is called “foobar.” Using {{foobar}} on a page would insert the heading and the text, “Some stuff,” underneath the heading, and there’d be an “edit” button beside the heading, like normally. Creating a template like this doesn’t work like it should; clicking on the “edit” button takes you to the template’s page, instead of taking you to the page on which it’s actually used.
PapíDimmi (talk | contribs) 11:12, 20 July 2016 (UTC)
It works exactly as it should, you are editing the page where the heading actually is, template documentation relies on this feature. --Redrose64 (talk) 20:09, 20 July 2016 (UTC)
That’s not what I am asking. I’m asking if there’s a way to make the edit link link to page on which the template is used. Is there? If so, how do I do it?
PapíDimmi (talk | contribs) 01:13, 23 July 2016 (UTC)
No. It is designed to edit the page where the heading actually is, not a page where it is transcluded to. --Redrose64 (talk) 09:02, 23 July 2016 (UTC)
@PapiDimmi: You might want to look into substituting a heading onto the page. For example if you have a template "foobar" with the content:
== {{{1}}} ==
{{foobar/content}}
And you call it with {{subst:foobar|My heading}}, then {{subst:foobar|My heading}} will be replaced with the following wikitext:
== My heading ==
{{foobar/content}}
If you don't use substitution, then the edit link will always go to the template, as Redrose64 says. — Mr. Stradivarius ♪ talk ♪ 09:26, 23 July 2016 (UTC)

Substitution ain’t what I want to do. Since there apparently ain’t no way to do this, I guess I’ll just forget about it.
PapíDimmi (talk | contribs) 20:39, 29 July 2016 (UTC)

Yes, there is no way to do it. A section edit link gives an edit box which starts with the section heading inside == ... == so the heading and it's level can be edited along with the contents of the section. That wouldn't work if you don't edit the page where the heading is located. PrimeHunter (talk) 20:48, 29 July 2016 (UTC)

What do you call it?

Which of these is appropriate?

Most people use the second if they know the method, and otherwise say "You need to use Template:stub." PrimeHunter (talk) 10:38, 30 July 2016 (UTC)

Example needs replacing

In § Examples with parameters, an example uses {{for}} as an example of parameters defaulting; specifically using {{for||Latins|Latin (disambiguation)}}. However, this usage of {{for}} is deprecated, because cases where it defaults to "other uses" should simply use {{other uses}} instead. Can someone replace it with a better example, please? {{Nihiltres |talk |edits}} 16:37, 12 August 2016 (UTC)

  Replaced with an example based on {{about}}, on revisiting the issue. {{Nihiltres |talk |edits}} 16:19, 7 September 2016 (UTC)

Name of language?

Sorry if this is a dumb question, but does the template "language" have a name? For example, "Let's convert Template:Internet Archive from ______ to Lua". Not that I propose doing so, what would one call it in comparison to other languages? Thanks. -- GreenC 15:28, 25 October 2016 (UTC)

There is no consistently used term. Templates use the same wikitext language as other wiki pages. Some wikitext features are just more common in templates. That leaves the question of whether we say wikitext, wikicode, wiki markup, or something else. Help:Wiki markup mentions those three but markup is rarely used about template coding. If you want a name to differentiate it from others at List of wiki software then you may say MediaWiki markup. If you just say "the template language" here then people will know what you mean. PrimeHunter (talk) 15:56, 25 October 2016 (UTC)
Ugh ok. I recalled in the distant past when the template language was being developed it had a name, but probably a false memory, or confusion with something else. thanks. -- GreenC 17:33, 25 October 2016 (UTC)
There is no template language. The code used in Wikipedia templates is exactly the same as the code used in other Wikipedia pages. Even the code used to pass parameters (code like |name=value on the outside and {{{name|}}} on the inside) is not specific to templates: see for example the code in User:Redrose64/editcountdesc which is used as a pseudo-template by User:Redrose64/constants, which is itself used as a pseudo-template by other pages. --Redrose64 (talk) 20:36, 25 October 2016 (UTC)

escaping pipes for table argument of template?

I'm trying to pass a wikitable as the last argument of a template, but I'm not understanding the behavior here in which the table argument seems to be completely ignored if i escape the pipes with {{!}}. (And, of course, if i don't the escape the pipes, then it doesn't work either.)

template: Template:Shogi diagramtest

example: Template talk:Shogi diagramtest#escape pipe ?

(cf. Template:Shogi diagram as used in Double Wing Attack)

Is there a solution?

thanks in advance – ishwar  (speak) 05:20, 31 May 2016 (UTC)

@Ish ishwar: Yep, you need to escape the equals sign as well. Otherwise, instead of the template thinking that your wikitable is in parameter number 86, it thinks you are using a named parameter called {| class. I've made the change for you on your test page here. Best — Mr. Stradivarius ♪ talk ♪ 05:44, 31 May 2016 (UTC)
Thanks. I didn't know that needed to be escaped as well. – ishwar  (speak) 06:03, 31 May 2016 (UTC)
So, this works for simple templates, but it doesn't work for passing a table argument to a module via a template:

module

{{shogi diagramtest 
| 
| '''Double Wing Attack'''<br />position after 4 moves
| ''none''
| lg | ng | sg | gg | kg | gg | sg | ng | lg 
|    | rg |    |    |    |    |    | bg |    
| pg | das| pg | pg | pg | pg | pg | pg | pg 
|    | dat|    |    |    |    |    |    |    
|    | pgl|    |    |    |    |    | ps |    
|    |    |    |    |    |    |    | uat|    
| ps | ps | ps | ps | ps | ps | ps | uas| ps 
|    | bs |    |    |    |    |    | rs |    
| ls | ns | ss | gs | ks | gs | ss | ns | ls 
| ''none''
| 
{{(!}}
{{!}}- 
{{!}} 1. {{!}}{{!}} P-2f {{!}}{{!}} P-8d
{{!}}- 
{{!}} 2. {{!}}{{!}} P-2e {{!}}{{!}} P-8e
{{!)}}
}}

simple template

Lua error in mw.text.lua at line 25: bad argument #1 to 'match' (string expected, got nil).

{{{86}}}

ishwar  (speak) 03:22, 21 June 2016 (UTC)

Ok. I've decided to not pass the html table through Lua and instead just pass the argument directly through the template. So, my question is moot. – ishwar  (speak) 23:56, 21 June 2016 (UTC)
It's probably a bit late for this, but you can escape the pipe symbol in templates by using the {{!}} magic word. And as for escaping equals signs, as well as the previous way mentioned (by using named parameters), you can also use {{=}}. Passing wikitables as arguments should be possible if you escape everything properly, but you're right that it's often easier to do it in Lua with Lua's multiline strings. — Mr. Stradivarius ♪ talk ♪ 05:33, 26 October 2016 (UTC)

Categories don't work when put in doc files

Categories don't work in doc files of these templates:
Template:IUCN 3.1 navmap/full
Template:IUCNCS
Template:IUCN status
Template:IUCN status/status
but work when put at the end of template code. Maybe someone could look at that. Links to cartegories are visible on pages of templates, but categories don't contain template pages. In cases 2-4 categories are inserted additionally into template code, so these templates are listed in categories. But this is only incorrect workaround. Thank you. Darekk2 (talk) 22:58, 6 January 2017 (UTC)

@Darekk2: I have made a null edit of Template:IUCN 3.1 navmap/full and it now appears in the category pages. A null edit (or any other edit) is sometimes needed to update link tables when a category is transcluded. PrimeHunter (talk) 00:06, 7 January 2017 (UTC)
I removed categories from templates 2-4 and they still work. Because it was about any edit, but not adding categories. Such null edit sometimes changes proportions of image dimensions in Wikipedia articles, when they are changed in Wikimedia Commons. I don't remember exactly what it was, but saving not changed article causes reformatting. Thank you. Darekk2 (talk) 01:04, 7 January 2017 (UTC)
(edit conflict) What do you mean by "categories don't work"? Which categories are affected? What do you believe should happen, what actually happens? --Redrose64 🌹 (talk) 00:07, 7 January 2017 (UTC)

Request help with vertical spacing on Template:FratChapter

Can someone help me with the spacing on Template:FratChapter See Lambda Sigma as an example. The boxes are too tall, *unless* the usages of Template:FratChapter are all on one line. I'd prefer to be able to put each on their own line.Naraht (talk) 18:40, 15 January 2017 (UTC)

I have removed a newline.[3] PrimeHunter (talk) 21:25, 15 January 2017 (UTC)

italics for foreign scripts = bad

Are templates smart enough to recognize foreign scripts by their unicode or something and not italicise them? This would be especially good for {{wiktionary}} Siuenti (talk) 01:41, 3 April 2017 (UTC)

Categories

How do you make templates put articles in tracking categories? In general, you are supposed to put categories at the end of the page. Does this not apply to tracking categories?

Thanks for your help!

Elliot321 (talk) 23:12, 8 May 2017 (UTC)

@Elliot321: All categories can be placed anywhere on the page. It's just our style (Wikipedia:Manual of Style/Layout#Order of article elements) to place them at the end when they are written directly in the source. PrimeHunter (talk) 23:23, 8 May 2017 (UTC)

Non-free image use

I'm wondering if there should be language added to this page about image use, in particular non-free image use. I occasionally come across a template where a non-free image is being used even though such usage is prohibited by WP:NFCC#9. I briefly scanned this page and was not able to find anything about image use at all. So, perhaps something along the lines of WP:DRAFTS#Preparing drafts, WP:UP#Non-free files or WP:UBX#Caution about image use should be added here as well. -- Marchjuly (talk) 02:54, 17 May 2017 (UTC)