Help talk:Template

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Wikipedia Help Project (Rated C-class, High-importance)
WikiProject icon This page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the Help Menu or Help Directory. Or ask for help on your talk page and a volunteer will visit you there.
C-Class article C  This page does not require a rating on the project's quality scale.
 High  This page has been rated as High-importance on the project's importance scale.
WikiProject Templates
WikiProject icon This page is within the scope of WikiProject Templates, a group dedicated to improving the maintenance of Wikipedia's templates. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.

Problem with if scripts[edit]

I'm a user on the Danish version of Uncyclopedia ([1]). I've been trying to get this template to work in a few days, but somehow it just won't do as I want. It's meant to create a table with two rows and a picture to the right. In the upper row, there is going to be security marks for a product, while the lower row is going to have up to four columns with product descriptions.

The problem lies in the upper row, as the lower row already works. Se the result here: [2]

Here's the script (most of it is in English; only security mark descriptions are in Danish). You should look at the script of this page, as Wiki puts everything into one line here:

{| border="1" class="metadata" style="width:100%; background-color:rgb(255,102,0)" | {{ #ifeq: {{{picton|0}}} | 0 | colspan="2" | }} style="align:center;" | {{ #if: {{{1mark|}}} | {| | [[billede:{{ #switch: {{{1mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{1mark|}}}.gif | #default = {{{1mark|}}} }}]] |- ! <big>{{{1head|}}}</big> |- | {{{1text|}}} |} | }} {{ #if: {{{2mark}}} | {| | [[billede:{{ #switch: {{{2mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{2mark|}}}.gif | #default = {{{2mark|}}} }}]] |- ! <big>{{{2head|}}}</big> |- | {{{2text|}}} |} | }} {{ #if: {{{3mark}}} | {| | [[billede:{{ #switch: {{{3mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{3mark|}}}.gif | #default = {{{3mark|}}} }}]] |- ! <big>{{{3head|}}}</big> |- | {{{3text|}}} |} | }} {{ #if: {{{4mark}}} | {| | [[billede:{{ #switch: {{{4mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{4mark|}}}.gif | #default = {{{4mark|}}} }}]] |- ! <big>{{{4head|}}}</big> |- | {{{4text|}}} |} | }} {{ #if: {{{5mark}}} | {| | [[billede:{{ #switch: {{{5mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{5mark|}}}.gif | #default = {{{5mark|}}} }}]] |- ! <big>{{{5head|}}}</big> |- | {{{5text|}}} |} | }} {{ #if: {{{6mark}}} | {| | [[billede:{{ #switch: {{{6mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{6mark|}}}.gif | #default = {{{6mark|}}} }}]] |- ! <big>{{{6head|}}}</big> |- | {{{6text|}}} |} | }} {{ #if: {{{7mark}}} | {| | [[billede:{{ #switch: {{{7mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{7mark|}}}.gif | #default = {{{7mark|}}} }}]] |- ! <big>{{{7head|}}}</big> |- | {{{7text|}}} |} | }} {{ #if: {{{8mark}}} | {| | [[billede:{{ #switch: {{{8mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{8mark|}}}.gif | #default = {{{8mark|}}} }}]] |- ! <big>{{{8head|}}}</big> |- | {{{8text|}}} |}|}} | {{ #ifeq: {{{picton|0}}} | 1 | rowspan="2" width="{{{pictwidth|}}}" }} | {{ #ifeq: {{{picton|0}}} | 1 | [[billede:{{{pictaddr|}}}|{{{pictwidth|}}}]] }} |- | {{ #ifeq: {{{picton|0}}} | 0 | colspan="2" }} | {{ #ifexpr: {{{cols|1}}} >= 1 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{1col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 2 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{2col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 3 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{3col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 4 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{4col|}}}</div>}} |} — Preceding unsigned comment added by (talk) 18:00, 16 November 2008

Template naming conventions[edit]

I've suggested standardizing template naming, at Wikipedia talk:Template namespace#Template naming conventions. If you're frustrated with typing template names and constantly guessing at the right capitalization and spacing, please chime in. Michael Z. 2009-01-10 17:46 z

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

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)

escaping pipes for table argument of template?[edit]

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:


{{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: bad argument #1 to 'gsub' (string expected, got nil).


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)

Using heading in a template[edit]

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}}} ==
And you call it with {{subst:foobar|My heading}}, then {{subst:foobar|My heading}} will be replaced with the following wikitext:
== My heading ==
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?[edit]

Which of these is appropriate?

  • “You need to use the {{stub}} template.”
  • “You need to use {{stub}}.”
  • “You need to use the stub template.”
    PapíDimmi (talk | contribs) 02:56, 30 July 2016 (UTC)
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[edit]

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)

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

Name of language?[edit]

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)

Categories don't work when put in doc files[edit]

Categories don't work in doc files of these templates:
Template:IUCN 3.1 navmap/full
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[edit]

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)