Help talk:Templates


Templates not refreshing[edit]

I hope I'm posting this in the right place. Anyway, I created a template and had its text say Hello, welcome. It worked fine. However, when I updated the template to say Hello, welcome to my wiki -- all the pages that had {welcome} did NOT update to refresh with the next text, they still had the old one. How do I get pages to auto refresh?

For those who find this page searching for the answer to updating templates on certain pages, this is a caching issue. If you need to refresh a specific page with a template that you've modified, load the page in question and append ?action=purge to the end of the URL. See Manual:Purge for details.

-- 17:00, 3 November 2014 (UTC)


Should the fact that any page can be used as a template be mentioned, or should it remain undocumented magic? -- Duesentrieb 16:35, 16 January 2007 (UTC)Reply[reply]
I did see that mentioned someplace just a second ago. Martin | talkcontribs 22:13, 22 February 2007 (UTC)Reply[reply]

Pass Variable into Hidden Section Header[edit]

I'd like to be able to pass a variable into a section header that is to be hidden from the TOC, like so:


====Header: {{{1}}}====


and for it to come out as Header: variable

When I attempt to use {{TemplateName|variable}}, it comes out as Header: {{{1}}}

The xh4 tags I'm using come from here:

How can I accomplish this?


Ok I cant seem to work out how this thing works at all, I try and copy and paste the code here and it dont work. what am i doing wrong?


Thats what I put for a test template and all i get is the title come up Object

Any ideas


Templates works only as transformation. In your wiki you have to create Template:Object page if you want to use template named Object, try something more simple as first template.

I think this help is well understandable. Maybe another example will be good for you.

In your wiki edit page
Write there something like:

 Your first argument:<b>{{{1}}}</b><br/>
 Your second argument:<i>{{{2}}}</i>

save the page (stop editing)

somewhere in your wiki edit some another page and insert here code:


It was not working without 1= and 2= for me in wiki 1.9.3 (bug)

when you try preview now, you will see:
Your first argument:text1
Your second argument:text2

I hope it's clear now, {{{1}}} from template page will be replaced with everything what is after 1=

--Betlista 17:53, 17 May 2007 (UTC)Reply[reply]

Templates with/for images[edit]

where should i place this image[edit]

where should i place picture01.png ?

How would I create a template where I pass only the name of an image (e.g. 'picture01.png'), and within the template this name is transformed into something like



Going one step further, I want to do it the 'Semantic MediaWiki' way, ie. again pass only the name of the image, and the template does the rest, ie.

The solution is to use accurate wiki coding for the images, and make sure the image is locally hosted on your wiki.


As long as you follow the appropriate formatting syntax, you should be fine.

Templates inside parameters[edit]

At my wiki I have a template called Shape and a template called R strange. The original intention was to put {{R strange}} inside the Shape template, but writing {{Shape|{{R strange}}Name of shape|other parameters}} doesn't work, rather it makes it be interpreted as {{Shape|other parameters}}. Is there any way to nest templates like this?

If not, I'll likely have to do some crazy positioning stuff with CSS.

- Keiji 16:37, 18 June 2007 (UTC)Reply[reply]

Never mind, I got it to work.

- Keiji 16:57, 18 June 2007 (UTC)Reply[reply]

How??? Slamlander 05:31, 25 October 2007 (UTC)Reply[reply]
It seems to be impossible, also below. JackPotte 06:33, 16 August 2010 (UTC)Reply[reply]

[Resolved] Why will a table row's text output in bold?[edit]

Can anyone explain to me why this code produces bold text? I can't figure it out. Thanks in advance.

{|style="width: 99%; border: solid #000000; text-align=center;"
! style="background:#CCCCCC;" | This article or section is currently empty, but the author intends to fill it in at a later time.  It should not be deleted.

-- 00:38, 24 June 2007 (UTC)Reply[reply]

It's because of the "!" at the beginning of that line. Replace it with "|" and you'll be happy ;-)
In addition you have to replace the "=" within "text-align=center" with ":" – otherwise it won't have any effect. --:Bdk: 01:03, 24 June 2007 (UTC)Reply[reply]
Thanks a lot for the help, but why is it that a ! instead of a | makes it bold? -- 01:15, 24 June 2007 (UTC)Reply[reply]
See Help:Tables. --:Bdk: 01:42, 24 June 2007 (UTC)Reply[reply]
Thanks again. Not sure what the rules are on this particular wiki about deleting, so I don't want to delete this topic myself, but I go the info I needed. -- 02:02, 24 June 2007 (UTC)Reply[reply]

Default templates?[edit]

Is it possible to create a template that is instantiated automatically without the user's intervention?

I've got a family wiki that many people edit. I'd like pages created from one particular page to all automatically start with a template. It's a collection of recipes. The procedure is to add the name to that page. When they link to the new page, I'd like it to automatically start with a default recipe format...

Thanks! (twinotter) 19:12, 10 July 2007 (UTC)Reply[reply]

That goes beyond templates and into boilerplates, or parameterized templates. Using templates this way actually makes your pages harder for your users to edit. At that point, you might be better off with a specialized PHP page. My recommendation is to do a standard page header template and show your users how to use it. -Slamlander 05:23, 25 October 2007 (UTC)Reply[reply]

Quick installer, perhaps?[edit]

If one were to install MediaWiki on their server, is there a chance there's an installer that comes with a bunch of templates? If so, a link to such a program would be nice. - Ahren 1:46 EST

Optional Fields?[edit]

As my question pertains to template use, I suppose this is where it goes. Is there a code for optional fields in a template? For example (Code I use is below): Say I want it set so that rank does not appear, if the field is not filled in, how does one do that? Thanks for any help someone can give.

{| align="right" border="1"
| colspan="2" align="center" | '''{{{name}}}'''<br/>[[Image:{{{image1name}}}|{{{image1size}}}px]]
| '''Name:'''
| {{{name}}}
| '''Affiliation:'''
| {{{affiliation}}}
| '''Rank:'''
| {{{rank}}}
| '''Homeworld:'''
| {{{homeworld}}}
| '''Species:'''
| {{{species}}}
| '''Gender:'''
| {{{gender}}}
| '''Date of Birth:'''
| {{{dateofbirth}}}
| '''Age:'''
| {{{age}}}
| '''Height:'''
| {{{height}}}
| '''Weight:'''
| {{{weight}}}
| '''Status:'''
| {{{status}}} <small>({{{statusyear}}})</small>

--TheSisko 22:28, 19 August 2007 (UTC)Reply[reply]

First, make sure you have the parser functions m:Help:ParserFunctions#Installation installed and working. Then you can do the following;

| '''Rank:'''
| {{#if:{{{rank|}}} | {{{rank}}} }}

Give that a try and let us know if you got it working =)

Thank you for mentioning this ParserFunctions extension, a lot of wasted time until I found that, thanks!

Infobox class??[edit]

I've just installed my first wiki - 1.10.1 and trying to setup some Infobox templates. The problem is there seems to be no Infobox class defined anymore? The various files I find online that have it, such as monobook.css and common.css seem to be competely different to the css files in the 1.10.1 package. I'm guessing something has changed quite dramatically in recent versions? What am I missing? --DJS68 02:09, 1 September 2007 (UTC)Reply[reply]

I'm not a PHP programmer, but this line doesn't look right in monobook.php -
<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?<?php echo $GLOBALS['wgStyleVersion'] ?>"; /*]]>*/</style>
--DJS68 02:29, 1 September 2007 (UTC)Reply[reply]
nope that's not the problem :-( --DJS68 02:37, 1 September 2007 (UTC)Reply[reply]

Templates Outside the Template Namespace[edit]

I just felt like sharing this:

  • Any page that has data in it can be used as if it were a template. Just enclose the page title in double curlies like so:
This would import expand this page into on whatever page you were editing.
  • A special addition needs to be made if you are trying to use a page from the "(Main)" namespace since a call to:
is equivalent to a call to:
If the page you want to use as a template is in the "(Main)" namespace, you must precede the page name with a colon (:) like this:

My apologies if this has already been discussed elsewhere. --Egingell (talk) 20:58, 2 September 2007 (UTC)Reply[reply]

That's called transclusion. --Thnidu (talk) 02:06, 13 September 2012 (UTC)Reply[reply]

Template Migration[edit]

I have a number of wiki's that I maintain and I want the same templates on all of them. How do I replicate the whole batch (about 36 of them) in one go?

- Slamlander 05:37, 25 October 2007 (UTC)Reply[reply]
Use Special:Export and Special:Import. Or you could try remote transclusion. Jlerner 18:45, 16 November 2007 (UTC)Reply[reply]

Templates Args[edit]

Any best practices advice or example for dealing with unnamed template parameters? And possibly mixed ones? I would like to be able to write a template like this the following. And easily access the unnamed parameters. Using the variable and control structure extensions to for/while loop through the {{{ {{#var:{{i}} }} }}}} to manufacture a "argv[]/argc" was the best I can come up with, but it seems to be a pretty intensive.


Thanks --Gmillerd 10:44, 26 November 2007 (UTC)Reply[reply]

Template Overload[edit]

Hi there, I have got a question: We have some templates which we use A LOT, even A LOT on one single page. It has an ID as parameter and outputs an icon + a text. The software stops converting the templates at some point and this is kinda anoying. anyone with ideas for that? or can we change the "max templates"-value? maybe someone could even add this pint to the article. greets, 15:28, 24 January 2008 (UTC)Reply[reply]

How do the Wikipedia Template: Cite book and Template: Cite work?[edit]

I'd like this in conjunction with my wiki page... but currently I can't figure out the implementation.-- 17:08, 2 February 2008 (UTC)Reply[reply]

Hmmm wikipedia:Template:Cite and wikipedia:Template:Cite book hey? Use the 'view source' tab to see their wiki text.
You should just be able to create a page called "Template:cite" on your own wiki and put in the follow wikitext:
<span id="{{{ref}}}" name="{{{ref}}}" class="citation">{{{author}}},  ''{{{title}}}'',  [[{{{publisher}}}]],  [[{{{date}}}]].</span> get a similar effect. I've missed of the 'noinclude' documentation section which is not necessary, and makes it more complicated. (it uses another template "wikipedia:Template:Documentation" to transclude documentation from a sub-page)
Now the 'Cite book' template is more tricky. I think it's using a parser extension. Probably Extension:Cite/Special:Cite.php, which you would have to install on your wiki, if you wanted it to work in exactly the same way. You can probably think of a more simplistic way of acheiving what you need though.
Templates on wikipedia tend to be rather more complicated than they need to be, and certainly not designed to make it easy to copy them. I was thinking actually we could kick off a project similar to Project:PD help, but for supplying a simple bunch of standard tempates for a new wiki installation.
-- Harry Wood 11:15, 4 February 2008 (UTC)Reply[reply]

[RESOLVED] Missing parameter[edit]

Let's say i define 2 parameters. When only 1 is called it will display {{{param2}}}. Is there a way to let it fall back to and call {{{param1}}} in such cases? --Subfader 20:04, 29 February 2008 (UTC)Reply[reply]

--Egingell 16:44, 1 March 2008 (UTC)Reply[reply]
Ok how to add it? I have the template: [[Media:{{{1}}}|{{{2}}}]]. Now without a defined param2 it should work like this: [[Media:{{{1}}}|{{{1}}}]]. --Subfader 09:57, 28 March 2008 (UTC)Reply[reply]
Got it now! Thanks. --Subfader 18:31, 10 April 2008 (UTC)Reply[reply]

A parameter starting with a single "+" sign is not processed as expected[edit]

I wrote a template where a parameter holds a telephone number (its content looks like "+123 (456) 78901234"). If I type something like this:

|Phone=+123 (456) 78901234

It's not processed correctly and the value is displayed on the wrong position. If I type something like this:

|Phone='+123 (456) 78901234'

The phone number is displayed the right way, but has the sorrounding quotes. How do I pass a parameter starting with a "+" sign to a template? Thanks --Major² 10:08, 31 March 2008 (UTC)Reply[reply]

Please tell us what the template definition looks like -- Duesentrieb 12:30, 31 March 2008 (UTC)Reply[reply]
This is a really simple template used to display business card info within a table:
! colspan="2" style="text-align: center; color:#4b4b4b; background:#E2F0E8;" | {{{Name|{{PAGENAME}} }}}
! align="right"|Address
|{{{Address}}}<br />{{{ZIP}}} {{{City}}} ({{{State}}})<br />{{{Country}}}
|- style="vertical-align: top;"
! align="right"|Phone
––Major² 23:59, 31 March 2008 (UTC)Reply[reply]

[RESOLVED] replace paramter if ...[edit]

Parameters: I use [[:File:{{{1}}}|(desc)]] to create a link to desc page of {{{1}}} which is the file name. Now sometimes it can happen that this parameter is an external link. In this case the desc link shouldn't show up. I dunno much about #if so is there a way to e.g. if param1 = http... then "(desc)" = "-" or something? --Subfader 15:17, 6 April 2008 (UTC)Reply[reply]

Included Titles Cannot Be Edited by Subsection[edit]

A template that includes a title cannot be later edited by subsection. The problem is, once the information is filled in and saved, if you want to edit that subsection, the EDIT link goes to the Template structure instead of the content. Is there a way to avoid this? Template example follows:

=== {{{Title}}} ===
* '''Members''': {{{Members}}}
* '''Topic''': {{{Topic}}}
* '''Responses''': {{{Responses}}}

The majority of our users are non-coders and will likely not be able to figure out that they need to use the Page edit link (at the top of the page) instead. Ideas? Samspectre 18:21, 30 April 2008 (UTC)Reply[reply]

Yeah. This isn't really a bug of the software because in many uses of templates, the behaviour (to edit the section within the included template) is the most logical/user friendly thing to do. Say for example you set up a single template which you bring in to your 'Home Page', and that template contains section headings and all the text content, the user expects to edit the text contents, therefor they need to be editing the section within the template.
I see your problem though. Because you're passing in text content in parameters from the including page.
Some things which don't really solve the problem, but in case you're not aware:
You can switch off the [edit] links using the __NOEDITSECTION__ magic word.
You could disable edit link of a particular section by making it not a real heading, so instead of === {{{Title}}} === just do something like <font size=+1>'''{{{Title}}}'''</font>
You could leave an explanatory note to be seen by anyone editing template definition, using HTML comments. Something like: * '''Members''': {{{Members}}} <!-- text passed in via the 'Members' parameter from the page which includes this template -->
I appreciate non of these things offer an ideal solution for you. Anyone else have suggestions?
-- Harry Wood 10:11, 1 May 2008 (UTC)Reply[reply]
No, unfortunately not. But I have exactly the same problem.--Gollum 16:09, 15 May 2008 (UTC)Reply[reply]
Everybody has this "problem". It is a limitation of using templates. There is no practical way, other than to use the suggestions above, to avoid this. There *might* be a way to tell the software that you're editing templated content, but I think it would generate unecessary server and database strain. I, personally, use the __NOEDITSECTION__ method to prevent the [edit] links from showing up at all. It doesn't matter where you put it, I put it in the template page itself. --Egingell 05:00, 16 May 2008 (UTC)Reply[reply]

Choosing between templates on the same page[edit]

We are working on a Wiki for product information. Each product page holds a (long) list of parameters on that specific product. Now we would like to create multiple templates that display these parameters in different ways concerning their order, selection and format. the user should be able to choose between different display styles, while the editors just have to work on one page, which holds all information. Is there any possible way to do so? My best, --Gollum 16:19, 15 May 2008 (UTC)Reply[reply]

Did you ever happen to solve this problem? I am looking to accomplish the same thing!

input tag filled with a template value[edit]


Is there any way to display input tag filled with template values within a page?


<html><input type="checkbox" checked="[[Delivery::{{{Delivery|}}}]]" disabled></html>

"Delivery" has value "False". In the page should now appear an unchecked checkbox. The checkbox is checked because the placeholder Delivery:: has not been replaced by the template engine. The html source code is:

<input type="checkbox" checked="[[Delivery::{{{Delivery|}}}]]" disabled>

I suppose thats through the "<html>" tags that I used in order to display the input box as html control (and not as plain text).

Thx for suggestions. kati

I have the same problem, only a slightly different scenario. I use PDF Include to embed PDF files into a page. The syntax is defined as
<pdf width="800" heigth="800">Path</pdf>

This works just fine until I try to insert the path via template. The result looks like this

<pdf width="800" heigth="800">{{{Path|}}}</pdf>
instead of
<pdf width="800" heigth="800"></pdf>

which naturally throws an "Invalid URL" error. So my guess is that html is being processed before templates are translated into their final values. Is there any way to create a workaround? The path variable is generated through an upload form, as well as width and heigth depending on format, and I can't expect my users, who are mostly rather technically inept, to manually enter the html tag for this task. Thank you in advance.

UPDATE: I have found a well working solution by adding the Iframe Widget to the Wiki. (Iframe Widget) With this, I make a nested template call by including the Iframe template into the template that holds the PDF path and handing the path variable to the url like this:


This way I can dynamically embed a PDF file into an article, with the PDF path being generated through an upload form for example. No manual editing of the article source à la PDF Include Extension is necessary anymore.

Even though this is no general solution to the html/template problem, it still helps in some use cases.

One possible solution is to use the parserfunction #tag instead. This is a wrapper which can be used on every tag available. See meta:Help:XML-style_tags#Tag_function. --Mglaser (talk) 09:23, 13 October 2016 (UTC)Reply[reply]

This worked for me[edit]

Apparently, the HTML tags are not really acting as HTML tags. They are instead telling the parser (not the browser) how to render the text to follow. So, you can simply throw in an end tag where ever, put in the variable, and restart the html again.

Blah blah, then an end tag before you insert a variable,<br> 
<br>and any additional text.

Templates inside parameters[edit]

Hi, I'd like in my wiki a structure like:

 |detailedDescription={{stub}} ... text of the description}}

In other words to use use a template as parameter of another template call.

The problem is that the interpreter reads the first closed curly brakets as closure of the template call, so it passes to template:detailedDescription only '{{stub'.

How can I make template:detailedDescription to accept the complete text and to show the content of {{stub}} in the final page?

Thank you,

--Dongiulio 14:24, 29 October 2008 (UTC)Reply[reply]

Special characters as template parameters[edit]

Hi, I'm trying to write a template in wikibooks (MediaWiki 1.14alpha — r44990) which needs to accept "special characters" as parameters, like: '*', ';', '='... (see delimiters list). I'm trying something like this (see template:Ada/delimiter):

 [[Ada Programming/Delimiters/{{ #switch: {{{1|}}}
  |..=double dot
  |&#124;=vertical line
  |>&#61;=greater than or equal to
  |<&#61;=less than or equal to
  |#default = {{{1}}}

However, some invocations work (e.g. with &, ', +...), but others don't (e.g. *, ;, :...). In the cases that don't work directly, sometimes it works using the HTML entity (e.g. &#42; for *), sometimes when using the named parameter ({{Ada/delimiter|1=/=}} for '/=' delimiter). Can I write something in the switch for not havin to use the HTML entity or the named parameter? Thanks! —surueña 23:03, 29 December 2008 (UTC)Reply[reply]

Done, I've just to remove the default case. Of course, for those delimiters containing a '=' named parameter should be used ({{Ada/delimiter|1=/=}} for '/=' delimiter), and the html number (&#124;) should be used for the | character (or the {{!}} template). But, does the need to remove the default case for the '*', ';'... parameters can be considered a bug? Thanks! —surueña 12:34, 30 December 2008 (UTC)Reply[reply]
Arrg, it doesn't work yet! The problem is that the switch returns void for several values, including when the text contains a '='. I read it in the documentation this behavior of #switch:, any plan to allow it when using an html number entity? Thanks —surueña 12:54, 30 December 2008 (UTC)Reply[reply]
What does the pipe symbol do? I see some logic using {{{1}}} and some using {{{1|}}} (the latter one has an extra "|" in it). But I can't seem to find any manual page which explains the reason for the symbol. Does anyone know? --Elonka 21:50, 3 February 2009 (UTC)Reply[reply]

Unknown Number of Variables beforehand[edit]

Hello. I am trying to create a template but I don't know the number of variable a priori. I want to allow editors to add any number of items in a list but I don't know the number beforehand. Is this possible? How do I do it?


One way I've seen this done is by creating a template that takes lots of optional parameters. {{#if: {{{PARAM|}}} | {{{PARAM}}} }} can be used to include/exclude each part depending on if that parameter is specified. For example, in Template:Infobox the parameters {{{data1}}} to {{{data80}}} are all optional parameters. The sub-template Template:Infobox/row is used to render each row individually and uses {{#if:{{{data|}}} ... to determine if the row is shown. Servel333 (talk) 16:49, 16 July 2012 (UTC)Reply[reply]
#if: is a parser function. To quote ... hmm, somebody who didn't sign their name... above in Optional Fields?:
First, make sure you have the parser functions m:Help:ParserFunctions#Installation installed and working.
--Thnidu (talk) 02:17, 13 September 2012 (UTC)Reply[reply]

Heading level and templates[edit]

How can I make a template where the heading level matches the page it is included on? For example, if the template is included under a level 1 heading, headings on the template would be level 2. If it was included under a level 2 heading, the headings on the template would be level 3.

One way I found that works is to have a named parameter passed into the template that contains the relative "top" level "equals string" for the template to use. For example:
(template use)
(template contents)
{{{h|==}}} Top header {{{h|==}}}
{{{h|==}}}= Second level header ={{{h|==}}
It's not pretty, but it works and makes sense.
WilliamsJD 21:01, 31 January 2012 (UTC)Reply[reply]

Remove braced variables from article?[edit]

Is it possible, in a way other than removing the variable from the article, to remove the triple-braced template variable from articles when the variable has not been specified?

I assume you mean that when, say, the second parameter isn't supplied, you'd rather not have {{{2}}} displayed in the article that included the template. Correct? If so, just give the parameter an empty default value in the template. Use {{{2|}}} rather than {{{2}}} when referencing the parameter in the template. --Vjg 16:03, 9 March 2009 (UTC)Reply[reply]
Yes, that is exactly what I meant... and that is exactly the workaround I came up with eventually... I just wish there was a permanent solution. Thanks though!!! --Bsmithme 21:50, 9 March 2009 (UTC)Reply[reply]

Documentation Page[edit]

Where do you place the Documentation Page? namespace:Template:Info Box xxx

Thank You stnick @ wikiwood [1]

Include the following within the template page:
After saving, view the template page again and you'll see an (empty) Template documentation box.
Hit the edit button, and start writing your template documentation. JRV (talk) 18:06, 26 July 2012 (UTC)Reply[reply]
I use to place the documentation in '''Template:Template name/Docu''', which is Template:Info Box xxx/Docu in your example. Ulf Dunkel (talk) 07:41, 8 June 2023 (UTC)Reply[reply]

Blank Default Parameters[edit]

This seems like a simple question but from all my googling I can't figure out an answer. How can I give a named parameter an empty default value, so that if someone using my template does not fill in every parameter, the undefined parameters simply don't show up?

Example: In my template there is a named parameter, [[{{{Subcategory 1}}}]], which creates a link to an internal page named Subcategory (or whatever is defined by the template user). Right now, if no subcategory is defined, [[]] shows up on the page. How can I make it so that nothing shows up if the Subcategory 1 parameter is left undefined?

I appreciate any help, have pity on a Mediawiki newbie!


Use {{{Subcategory 1|}}} (notice the pipe character after the "1"). INVERTED 20:41, 25 July 2009 (UTC)Reply[reply]
It sounds like what you want is {{#if: {{{Subcategory 1|}}} | [[{{{Subcategory 1}}}]] }} Servel333 (talk) 16:52, 16 July 2012 (UTC)Reply[reply]

Wiki equals HTML[edit]

This is an example of an wiki format {{Example}}. It is a template. Lets say it has news updated on it and it changes on every page the template is added on. What would this simple wiki format be if it was in HTML? I want to use it on my HTML website and want it to be updated automatically when I change it on my wiki. Sachein 14:52, 12 May 2009 (UTC)Reply[reply]

You can't use template wikicode as HTML... if you wanted to do that, you'd need to do some rather complicated PHP. INVERTED 20:39, 25 July 2009 (UTC)Reply[reply]

Calling a Template on every Site[edit]

If I want a Template to display on every site what should I do?

Nobody has an idea how to display a template on every site? maybe some monobook modification?
What do you mean "every site". You aren't giving many details. Bud0011 00:13, 6 January 2011 (UTC).Reply[reply]
I guess you mean how to display a template on every page of your wiki, right? Here's a how to. You need access to your LocalSettings.php file on the server:
Display template on every page Ulf Dunkel (talk) 07:46, 8 June 2023 (UTC)Reply[reply]

Unclear behavior of template substitution[edit]

I found out the hard way tonight that pages in the main namespace need two colons when using template substitution as in: {{subst::Page Name}}. I guess this is the logical product of adding subst: to {{:Page Name}}, but its not immediatly obvious and might be worth explicitly stating.-- 04:33, 8 June 2009 (UTC)Reply[reply]

A simple "how to" or tutorial section[edit]

I would like to suggest a simple "how to" or tutorial section. After reading this page I still have no idea how to create a template. Thanks

Template with large parameter causing MediaWiki crash[edit]

When I try to put a large parameter inside a template (six or so paragraphs), MediaWiki decides to send a blank response to the browser. Also, I tried splitting the text up to several parameters, but it seems that the total size of the parameters is what matters. Please fix this! INVERTED 17:32, 25 July 2009 (UTC)Reply[reply]

I Am UTTERLY Thick[edit]

Even with all the excellent documentation I have not been able to make the TOClimit template work on my site. I have tried over and over again, but nothing has worked yet. I am sure the problem is not with a lack of instructions but rather my utter lack of intelligence. Can someone please distil down the knowledge about how to implement templates so that it can be understood by a large brassica (hey! this suggests I can't even spell brassica correctly - I must be a cabbage).

Anyhow, I am making a plea for very clear, straight forward, instructions on how to get the TOClimit template to work. I am wanting to implement a Quality Manual documentation project, which has numerous headings but should only display them down to a limited level.

Hey, I am thick too :) - perhaps you can have a look if it is referencing any CSS or javascript - if your site does not have this, then it might not work. --Boy.pockets 01:59, 8 October 2009 (UTC)Reply[reply]

Cheadings and other Special Characters passed in as a template param[edit]

I want to be able to pass in a special character as the first item in a template parameter, but it does not seem to work. Something like this.

|reason=*all your hard work and
*great looks

A little thank you... for *all your hard work and

  • great looks.

hugs, Joe

Of course, I could add a
in front, but I don't want to do that. Is there anything I can do in the template to allow me to do that?--Boy.pockets 01:59, 8 October 2009 (UTC)Reply[reply]

  • I have the same problem. I cannot seem to google up a solution. Any progres with this? --Rob
    • Insert a new line in the template just before the parameter may be helpful. The template is changed from:
:::for {{{reason|{{{1}}}}}}. 
and allows the asterisk to be correctly interpreted:
Example sunflower image
Example sunflower image
A little thank you...
  • all your hard work and
  • great looks.
    hugs, Joe
{{User:Hamilton Abreu/testes/Thank you
|reason=*all your hard work and
*great looks
Example sunflower image
Example sunflower image
A little thank you...

dinner and

  • desert.
    hugs, Joe
{{User:Hamilton Abreu/testes/Thank you
|reason=dinner and
This last example looks a bit messy, though, so it might not fit your purpose. Hamilton Abreu 14:02, 5 February 2010 (UTC)Reply[reply]
  • I ran into this exact same problem today while trying to create a template that is to contain an ordered list. Adding a line break doesn't seem to be a valid work around either. Would love to have some light shed on this situation. --Kjoz 20:50, 4 February 2010 (UTC)Reply[reply]
    • Kjoz, adding a line break, followed by a new line, is a valid workaround: Hamilton Abreu 14:02, 5 February 2010 (UTC)Reply[reply]

A little thank you... for

  • all your hard work and
  • great looks.

hugs, Joe

|reason=<br />
*all your hard work and
*great looks

Template Above Title - and possible lock[edit]

Hi, I have created a template with a Padlock to go on semi and full protected pages. It currently goes under the title, and I am wondering how I get it to go above (like Wikipedia). Also, if possible, is there a way that only Admins can add this template to pages. Thanks in Advance.

Big problem with templates.[edit]

Maybe it's just me, i've tried using a variety of different codes and followed a lot of peoples advice but i just cannot get templates to work for me. I've even tried using the advice above with the:

Your first argument:{{{1}}} Your second argument:{{{2}}}

But when i go to implement it on another page, all that shows up is "Template:First". It's the same with any template i try, it just comes up with the template name rather than the template itself.

Please can you help me as i'm stumped

Please state the exact name of the template page (including its namespace) and the exact statement you are using to transclude it. Hamilton Abreu 17:23, 19 January 2010 (UTC)Reply[reply]

[RESOLVED] Defining parameters[edit]

Can one define a parameter within the Template? With a #switch function (for example) one can define an outcome, but I will want to use that outcome again and again in the Template without putting the whole #switch thing in again.

For example, a #switch on a parameter might have result options France=French | Germany=German | Austria=German etc, but what if I want to take the result ("French", "German" etc) and use it elsewhere? I ought to be able to say something along the lines "{{{lang}}}=X".

In VB one must "Dim" a variable, and then having given it a value and that variable can be used as often as you like. From what I have read, the only way I can think of doing it is to have a series of shell templates to hold the value and then feed it back. That cannot be right. I must have missed a trick.

Hogweard 22:16, 17 February 2010 (UTC)Reply[reply]

Ah; sorted out with Extension:Variables. Hogweard (talk) 12:31, 17 July 2012 (UTC)Reply[reply]

Source code of the page has &lt;tr&gt;&lt;th&gt; instead <tr><th>[edit]

Hi, I tried to import the TODO_LIST Temaplate by "Special:Import" page. No any errors or warnings were not appeared after submiting the Import form. But template is showed incorrect. I see

<tr><th class="mbox-text" style="text-align:left; padding:1px;">Файл:Stock post message.svg To-do list for Шаблон:Todo:</th>
<td class="mbox-empty-cell"></td></tr> 

instead nice header of TODO List. What is wrong? Please note, that


tags are occures in edit box of this page. It is very strange, because MediaWiki has it own specification of tables creating.

Code from edit box:

{| class="{{talk other|demospace={{{demospace|}}}|tmbox tmbox-notice|ombox ombox-notice}} {{#ifeq:{{{small|}}}|yes|mbox-small}}
{{#ifeq:{{{collapsed|}}}|yes|collapsible collapsed}} t-todo" style="border-collapse:separate; {{{style|}}}" cellspacing="4"
<tr><th class="mbox-text" style="text-align:left; padding:1px;">{{ . . . 

It is real problem or, my own mistake? How can I fix it?

  • MediaWiki version: 1.15.1
  • PHP version: 5.2.10 (apache2handler)
  • MySQL version: 5.1.34-community
  • URL:

Sorry for bad English :) —VaZia 21:35, 22 February 2010 (UTC)Reply[reply]

In the wiki where you imported the template, edit the template. Go to the bottom of the page, check if any of the links to transcluded pages appear in red, and list the red ones here. Hamilton Abreu 01:31, 23 February 2010 (UTC)Reply[reply]
I did not found any red links in the bottom of [2].--VaZia 21:32, 23 February 2010 (UTC)Reply[reply]
If none are red then you're probably missing the tmbox and ombox classes in your CSS. Have a look at the bottom section of Help:Templates, see if that helps. Hamilton Abreu 01:44, 23 February 2010 (UTC)Reply[reply]
Ok, I will check it. But I do not think that missing of CSS class can be cause of such bug in source of the page
&lt;tr&gt;&lt;th class="mbox-text" style="text-align:left; padding:1px;"&gt;
I saw it in FireBug. That is why pure html tags
<tr><th class="mbox-text" style="text-align:left; padding:1px;">Файл:Stock post message.svg To-do list for Шаблон:Todo:</th><td class="mbox-empty-cell"></td></tr>
appears on the page.--VaZia 21:32, 23 February 2010 (UTC)Reply[reply]
Yes, you're right about CSS not being the cause. It seems that your wiki is not allowing the use of the <tr> and <th> HTML tags, although in principle they should be allowed. Check MetaWiki:Help:HTML_in_wikitext for more details on this. I tried in your wiki to change the HTML tags to the WikiText equivalent; for example, replacing the line
<tr><th class="mbox-text" style="text-align:left; padding:1px;">{{
in the template, by
! class="mbox-text" style="text-align:left; padding:1px;" |{{
(notice the | before the {{) should produce the adequate <tr> and <th> HTML tags in the output instead of &lt;tr&gt;&lt;th&gt;. But your wiki just went down and became unavailable, so I couldn't test replacing the rest. Anyway, do you see where I'm going with this? Maybe you can try replacing the rest of them for the WikiText equivalent; the thing is, if in wikipedia the template is using the HTML tags instead of the WikiText, they're probably doing something funky that may not be possible to achieve with WikiText. So, the proper solution is to figure out why your wiki is not allowing the <tr> and <th> HTML tags in the first place. But I'm at the limits of my knowledge there. Perhaps someone more knowledgeable will read this and help. Hamilton Abreu 01:23, 24 February 2010 (UTC)Reply[reply]
Hamilton Abreu, thank you for your attention! Yes, template can be fixed by using |-,|,! instead <tr>,<td>,<th> or native table tags instead wiki markup for tables. But question is opened as before. Why my wiki is not allowing the use of the <tr> and <th> HTML tags? Now, I found the related link and will go there --VaZia 09:20, 24 February 2010 (UTC)Reply[reply]

Do you know HTML? It strikes me that the usual way to define a table would be:


But the template does:


mixing the <th> and <td> HTML tags inside a <tr>. I'm way out of my depth here, but maybe the template uses non-standard HTML (a trick) that MediaWiki identifies and tries to erase. Possibly related to the $wgUseTidy thing that the documentation keeps referring to, which seems to fix bad HTML. If this were the case, then wikipedia has the $wgUseTidy thingy and your wiki doesn't. Or the other way round: $wgUseTidy causes this, wikipedia doesn't use it and your wiki does. But please keep in mind that this is just an idea, I don't know what I'm talking about, at all. :-) Hamilton Abreu 15:02, 24 February 2010 (UTC)Reply[reply]

I confirm : Wikipedia uses tidy, and it is required to 'clean' complex templates such as some infobox. I installed is very easily : dnl the binary, put it in a 'tidy' subfolder of /includes/parser and add $wgUseTidy=true; in your Localsettings.php. This worked for me, an now I have infoboxes v2 on my local mediawiki. (by the way it is a shame to be obliged to use a 'cleaner' program to process the templates output ;) Phcalle 16:35, 31 March 2011 (UTC)Reply[reply]

Thanks for that, Phcalle. -- Hamilton Abreu 04:28, 2 April 2011 (UTC)Reply[reply]

Searchable template content?[edit]

I'm using templates to help format the content on my wiki, but I'm having a hard time figuring out a way to enable a user to search the content of what is entered into the template.

For example:

{{example|1=want to search for this|2=blah blah blah}}

When using the search bar, "want to search for this" doesn't bring up any search results. Is there anyway that I can let mediawiki search template content?

Cheers, Chan.mike 13:11, 31 May 2010 (UTC)Reply[reply]

By default, only a few namespaces are searched (usually the principal namespace and maybe a few others, depending on the wiki). Near the top of the page of the search results, there should be a box that allows you to select which namespaces to search. Select 'custom', press the button to deselect all boxes, select box "Template" and search again. Hamilton Abreu 22:36, 31 May 2010 (UTC)Reply[reply]
By the way, keep in mind that in your example "want to search for this" should not be found within the template itself, unless that string explicitly appears in the template code. Hamilton Abreu 22:38, 31 May 2010 (UTC)Reply[reply]

Space delimiter in external links causing issue in template.[edit]

Observe the following in a template I named Template:Tutorial/General, template follows:

<div style="border-style:double;text-align:center">
This is a general tutorial
<includeonly> about {{{tutorial-description|{{PAGENAME}}}}}
</includeonly>.<includeonly><br />
For further information see 
 {{{url-description|{{PAGENAME}} on Google}}}]</includeonly></div>

(Extra line breaks added to improve clarity).
To explain what I want this template to do:

I want it to accept 3 parameters: url, url-description & tutorial-description


{{Tutorial/General|tutorial-description=µTorrent|url=|url-description=µTorrent's homepage}}

Now, in the case of the example, it works just fine. However, if I create a new page and chose to omit the parameters it only works fine (using {{PAGENAME}} as tutorial-description, Google's search page as url and {{PAGENAME}} as external link name if the new page contains no spaces. If it contains a space the template breaks. This is obviously because the delimiter between link and name for external links actually is a space.
I tried fiddling a bit with parser functions but ended up facing the same issue - the first space found between external link and link name breaking the template.
If I create a new page Foo Bar with content


it parses to

This is a general tutorial about Foo Bar.
For further information see Bar Foo Bar on Google.

With link

Any help greatly appreciated. --Kharay1977 19:48, 19 July 2010 (UTC)Reply[reply]

I haven't analysed you question in detail, but would the Help:Magic words#URL data:
{{urlencode:Foo Bar}} → Foo+Bar, or
{{anchorencode:Foo Bar}} → Foo_Bar
be of any help, especially the second? Hamilton Abreu 21:26, 19 July 2010 (UTC)Reply[reply]
Thanks for that answer. Very useful indeed. {{anchorencode}} wouldn't have helped though. As that would've made the search parameter Foo_Bar as opposed to the intended "Foo Bar". {{urlencode}} did the trick though. Thanks. I don't know how I could've looked past right those little gems while browsing the help for a solution. *grateful aura*. --Kharay1977 22:11, 19 July 2010 (UTC)Reply[reply]

Using another page or template as parameters?[edit]

This may be covered as a Semantic MediaWiki situation, but I'm asking here, in case it's not...

I have a set of pages where one page is to be a summary of the other pages; the content on the other pages will be the same as on the summary page, and I would like to draw the details for the summary and the detail pages from the same location.

I'm thinking something like this:

{{SummaryRow | {{datapoints}} }}

For the summary page, and

{{DetailBox | {{datapoints}} }}

on the data points page

Another way of looking at this, is that I'd like to show the same *data points* with different structure on different pages.

Suggestions? Please go easy on me, I've only been playing with Wiki for less than a month! :)

—The preceding unsigned comment was added by (talkcontribs) 03:09, August 2, 2010 (UTC). Please sign your posts with ~~~~!

See m:Help:Template#Alternatives for extracting parts of a page to be used in another page. The common text can also be put in separate templates, to be used in different pages. To show data in a different way on different pages requires either putting each part in a different template, or combining data in such a way that subdata can be extracted, see m:Help:Array.--Patrick 12:34, 2 August 2010 (UTC)Reply[reply]

Is there any script to create sub template in a template[edit]

I wonder if template in mediawiki support sub template?

For the third time (#Templates_inside_parameters, #Templates_inside_parameters_2), we don't think that it's possible currently. JackPotte 20:20, 19 August 2010 (UTC)Reply[reply]
Templates inside parameter values are allowed: {{t1|{{tc}}}} gives startinend.--Patrick 00:09, 20 August 2010 (UTC)Reply[reply]
Yes, but we can't get "start{{tc|1}}end" by calling {{t1}} (like in {{t1|{{tc|1}}}}...). JackPotte 01:44, 20 August 2010 (UTC)Reply[reply]

Gallery In a Template[edit]

I'm trying to setup a template that has a gallery in it, but for some reason it won't work. Here is a basic example of what I'm having trouble with.




| File1 = File.png
| Desc1 = This is the description.

When the template is used in a page, the page remains blank. I've checked the HTML source, and it creates the table for the gallery, by it never puts the image or description in it. Anyone know what am I doing wrong?--TheAlmightyGuru 20:55, 1 October 2010 (UTC)Reply[reply]

Apparently, once <gallery> takes over you can no longer do parameter substitution. Maybe we've finally found what the {{#tag:}} magic word can be used for. If you replace the template by:
it will work. If you only get the image but no description, create template {{!}} with a single pipe char (|) as contents. Hamilton Abreu 01:35, 2 October 2010 (UTC)Reply[reply]
Tried this and it almost worked for me. How do you pass along information like width and perrow? 21:53, 2 July 2011 (UTC)Reply[reply]
Nevermind! Had a ephiany and got it - piped in after content instead of before. 21:57, 2 July 2011 (UTC)Reply[reply]
Correct. You can also pass them in:
Hamilton Abreu 12:57, 3 July 2011 (UTC)Reply[reply]

what does this mean?[edit]

I was wondering if anyone could explain what does the following tag does? <nowiki/> Thank you, Bud0011 18:35, 17 October 2010 (UTC).Reply[reply]

It prevents trimming:
p{{#if:x|<nowiki> q <nowiki/>}}r gives p q r,
also at the start and end of a template.--Patrick 11:43, 18 October 2010 (UTC)Reply[reply]
Cool. And thank you. Bud0011 16:32, 18 October 2010 (UTC).Reply[reply]

Template Problems[edit]

1) When I create template for my wiki, it shows 'broken' template, with many symbol similar this: #if in {{}}. I create all demanded templates, but situation doesn't change. why? Can you help me?

2) I want my wiki was easy to configure or create articles for my users and I need to give them usable template directly when they create articles. Can I do it? It's possible?

Related to #1, look into Parser functions. Your wiki maybe trying to use them, without the proper extension installed. Don't have anything for #2, sorry. Bud0011 19:48, 30 November 2010 (UTC).Reply[reply]
For the 2) the users can click on a button like this one in reading mode, and/or from the editing mode like those into the icon bar at the top of the writing window (herewith an example of their settings). In case of page creation, you've got also the option to use MediaWiki:Newarticletext. JackPotte 07:56, 1 December 2010 (UTC)Reply[reply]

import templates[edit]

Following the instructions of the article, I could create few templates. Especially I am interested in the {{cite journal| title=Where to get it?}}. For the compatibility of various wikis, it is important that all the wikis use the same; how to import it from wikipedia or citizendium? I tried to copypast some, but the result is ugly; some components are either missed or non compatible... Did anybody else meet such a problem? It would be good to add a subsection about import of templates. Tori 14:09, 10 March 2011 (UTC)Reply[reply]

On the origin site, go in special:export. Then, paste your templates pages names, and tick the box Include templates. If you clic on export, you will get a .xml file, to import in the special:import page of the destination wiki. JackPotte 19:50, 10 March 2011 (UTC)Reply[reply]

Template Naming Conventions[edit]

I'm sure there is no one standard for naming templates, but it would be nice to hear a couple suggested template naming standards. A few weeks ago I actually found a page that did an excellent job of giving this information, but I can't find it again. Anyone have this knowledge or know of a link?

It probably depends on your content. For instance, a Video Game Wiki will probably have Game-Based names for templates. Bud0011 20:26, 23 June 2011 (UTC).Reply[reply]
In general, wiki template pages are just pages, but in the special Template: namespace. Name them like you would name article pages. Ulf Dunkel (talk) 07:50, 8 June 2023 (UTC)Reply[reply]

Preventing a nested noinclude from breaking your template in version 1.12.0[edit]

[I'm not sure if this is a problem in later versions though] I tried putting a noinclude within a nowiki tag but the closing nowiki tag broke my template:
<noinclude>Pear<nowiki><noinclude>Banana</noinclude></nowiki>Apple</noinclude> will mean 'Apple' gets included in the template because the noinclude closing tag is translated instead of ignored.

To fix this, I encoded the entities:

With Banana as an example the need for nowiki tags is useless but in practice you may be putting category or template references in there.

Documentation of parameters themselves nonexistent - what does a pipe do at the end of a parameter?[edit]

I haven't been able to find any documentation of parameters. The templates documentation talks about USING parameters, but doesn't document the parameters themselves. I'm trying to find an answer to the question:

What does a pipe do in a parameter like this?:


It's not the pipe trick. The only place that form shows up in Help:Extension:ParserFunctions, is in an #ifeq test. It shows up in this talk page also, in various tests. Freenode #mediawiki guesses that the pipe functions for: "<Reedy> It's checking if it's set", but no further understanding of what exactly it's doing is available.

Line 3278 of includes/Parser.php has some code that seems to be checking for the pipe character, but I don't know why, or what it's doing when it finds it.

Once somebody explains this, then we can document it (and I can feel confident either using it, or not). Thanks.

Badon 20:02, 28 July 2011 (UTC)Reply[reply]

1. Would this be what you are looking for?

So that the note will look similar everywhere it is used, you can define a template called Template:Thankyou, for example. Although the note should look similar whenever a user thanks another user, its specific contents (i.e. the reason and the signature) will be different. For that reason, you should pass them as parameters. If we ignore the remaining elements to format the box and place the image, the core content of the template will be this:

'''A little thank you...'''
for {{{1}}}.
hugs, {{{2}}}
2. then, what file is "includes/Parser.php"?
3. next, "includes/parser/Parser.php" has this code as line 3278.
3277	function fetchTemplate( $title ) {
3278		$rv = $this->fetchTemplateAndTitle( $title );
3279		return $rv[0];
3280	}
4. Finally, as far as i know, the pipe-thing only comes into play when the Extension:ParserFunctions comes into play. Bud0011 17:49, 30 July 2011 (UTC).Reply[reply]
The pipe is used to specify a default value, in this case the default value is the empty string.--Patrick1 13:59, 6 August 2011 (UTC)Reply[reply]
Thanks! Badon 02:53, 9 August 2011 (UTC)Reply[reply]
If you are using a conditional parser function, the pipe helps to test if the parameter exists. For example:

{{#if:{{{1|}}}|display this}} If a template is called with a parameter like {{Mytemplate|MyParameter}} then this if statement will print the text "display this" as the parameter is not blank. If you did not supply a parameter then the text would not display. The nesting of the parenthesis can get quite tricky in multiple nesting of statements. 19:36, 17 July 2012 (UTC)Reply[reply]

Link table doesn't contain links from templates[edit]

I'm using categories, and i am creating links from within templates. MW1.17 The categories work fine, the target page gets a category from the template, the targetpage shows up correctly in the categorypage. This is not true for the links. I mean, the links work alright, but the Special page Special:WhatLinksHere, and the "File links" chapter on the Filepages do not show these links. Isn't this a mw bug? It sure is a pity.-- 09:34, 21 October 2011 (UTC)Reply[reply]

Importing Wikipedia Templates[edit]

I am trying to setup my own Wiki using the MediaWiki software. I need to import a subset of some of the Wikipedia templates but I am unable to do so since almost every template depends on another. Is there a way I can import the templates (to the last template depended upon) quickly?

Let's say that you want to import w:en:Template:Cite web. Go go w:en:Special:Export, type in "Template:Cite web" (without quotes) in the big text box and mark the middle check box. It may be a good idea to mark the other two check boxes too for convenience and licence compliance. --Stefan2 23:56, 14 December 2011 (UTC)Reply[reply]

Whitespace nightmare[edit]

There needs to be a section devoted to dealing with whitespace in templates. Badon 08:27, 13 December 2011 (UTC)Reply[reply]

  • I second this! (wish I knew the answer to put here)
    • It may be related to [3]

The "If you don't have import rights on the new wiki:" section[edit]

The XML file contains some XML entities which shouldn't appear in the MediaWiki edit box. I edited the section stating that you're supposed to replace those entities with the corresponding characters, but it may be more practical to copy the source from the MediaWiki edit box on the original wiki instead. All transcluded templates that you need to copy are listed below the edit box under the header "Pages transcluded onto the current version of this page:". --Stefan2 00:01, 15 December 2011 (UTC)Reply[reply]

usage of "substitute"[edit]

Under Usage, I'm changing the first sentence of the entry for {{subst:Name}} from

when used, this template link will be substituted with a copy of the contents of [[Template:Name]] in the source of the transcluding page, as of the time the page with the link is saved; the contents are then a part of the including page, and can be edited normally, separately from the original.


when this template link is used, it will be replaced once and for all with the content of [[Template:Name]] as of the time the page with the link is saved: a copy of the contents of [[Template:Name]] will be substituted for the template link. The contents are then a part of the including page, and can be edited normally, separately from the original.

We might also say

when used, this template link will be replaced with a copy of the contents of [[Template:Name]] in the source of the transcluding page ...

but that doesn't include the word "substitute", abbreviated in wikicode with the magic word subst.

The sentence isn't really ambiguous as it stands, but it supports a widespread confusion. Though the words substitute and replace refer to the same action, they are not equivalent. "Replace A with B" = "substitute B for A": so far no problem. But English also allows us to leave out the prepositional phrase, saying simply

  • "replace X" = remove X (and put something else in its place)


  • "substitute X" = (remove something and) put X in its place

Imagine this paragraph in a cookbook:

Despite their different textures, there are interesting similarities between honey and vinegar. For a sweeter taste, you may wish to try substituting vinegar in some of the recipes in this chapter.

and a resulting letter to the author:

I substituted vinegar for honey as you suggested in the dessert for my graduation party. It was terrible! What were you thinking?

Of course it's obvious that substituting vinegar for honey won't make a sweeter taste, and that the author should have written either "replace vinegar" or "substitute honey", or used the full expression with "with" or "for". But the results with code are a lot less obvious. --Thnidu (talk) 22:33, 2 May 2012 (UTC)Reply[reply]

Equals sign as a parameter[edit]

I created a template for mathematics blocks and I needed to pass equals signs without using any inconvenient workarounds (i.e. {{=}}), so I found an easy solution - disable named parameters at all. Unfortunately, there's no such standard setting, so I had to modify the code:

  • includes > parser > Preprocessor_DOM.php
  • Search for:
} elseif ( $found == 'pipe' ) {
  • Put false instead of true on the next line

Hope this will come in handy.

[SOLVED] Table as Parameter[edit]


It is possible to assign rather complex stuff in a parameter. I have not been able to figure out, how to pass a table to the template. Is this possible at all?

Example without a table

Template with some arbitrary wiki code as content

  • list item 1
  • list item 2

Example with a table (not-working)

Template with table wiki code as content


As you can see, the second example is messed up.


Mediawiki parses the "|" character expecting a new parameter after this. To escape it, you have to use nested templates to escape this character as Wikipedia does. Same goes for the "=" character. See links below for details.

Template for ASCII-art[edit]

I would like to create a template to help display ASCII-art. The only way I've found to display ASCII-art properly is to use the <pre> tag, but this tag does not appear to work with templates.

I create a template called {{ascii}} and I would like to pass it some ASCII-art, and have it formatted as:

<pre style="font: 125% monospace; border:none; background:#FFFFFF;">{{{1}}}</pre>

However, when I use the template like this:

{{ascii| :) }}


{{ascii|1= :) }}

I want the result to be:


But the result is:


Any suggestions? Is there a better way to do this? Thanks --Chibbie (talk) 16:58, 3 May 2013 (UTC)Reply[reply]

  • I think that the template doesn't like the ":" character. I don't know where you're editing this, but maybe using nowiki tags will do it for you? Starport592 (talk) 23:18, 12 May 2014 (UTC)Reply[reply]
    • I ran into this identical issue while trying to use the pre tags in a template. This denotes pre formatted text and any wiki markup and HTML markup inside that block will not be processed. Thus, instead of {{{1}}} becoming a variable, it instead outputs a literal {{{1}}}. The only work around is simply not use pre tags in templates where variables will have to go. Ihatefile007 (talk) 01:45, 14 December 2015 (UTC)Reply[reply]

Having Some Trouble Getting A Parameter's Default Value To Work[edit]

I have a template with a parameter of


. I want the default value of the parameter name to be "none". So I added


to my template. However, if I add the empty line "|name=" to the page calling the template, the template treats that blank space as the parameter as having been filled in, and instead of having a default value of "none", it simply is blank. I can remove the "|name=" line from the page calling the template, and the parameter shows the default value of "none" correctly. I would like to paste the same unfilled template into many pages, though, so it would be awesome if could leave values blank on those pages, but still have the default parameters from the template work as expected. If there is no way around this, I suppose I can just use none, but I would prefer the cleaner method.

Template disabling on Embedded page[edit]

Hi, it'll be nice to have opportunity to disable template on embedded page.
Problem description:
We have page (1), on which is template. This page is embedded to another page (2) (as part of an article). We don't won't to show templates on page 2. I think, that is now not possible. It's possible to develop it? Thanks.

Multiple entries on the same page using one template[edit]

I have a 'list_items' template that does the following:

Mr {{{NAME}}} has

  • {{{items}}}

for 'John' page, using Special:importCSV page, i imported all the data for 'John' in append mode which gives the following wikitext for 'John' page:

{ {list_items|John|mouse} }

{ {list_items|John|keyboard} }

{ {list_items|John|tv} }

and the following page is displayed for 'John':

Mr John has

  • mouse

Mr John has

  • keyboard

Mr John has

  • tv

what i want actually to have after the import is more:

Mr John has

  • mouse
  • keyboard
  • tv

how can i do that?

Parameter limit?[edit]

Is there an upper limit to the number of parameters a template can take? I would like to do something with 20+ parameters/arguments, but don't want to break the code. (if I matters, this template will be on a site, which runs some version of mediawiki)


Examples of each usage would be extremely helpful - Will the WikiWise please provide some? Thanks! —The preceding unsigned comment was added by (talkcontribs) 23:04, 25 November 2006.

Please support request for templates for new MediaWiki installs[edit]

Anyone setting up a MediaWiki wiki wanting to use templates, has to export/import them from another wiki (e.g. Wikipedia) or re-write and maintain some similar ones. This can create a confusing mess. There ought to be a simpler way to install a kept-up-to-date package of standard templates. Please support a request for this at Templates for new MediaWiki installs and at Bug 56388 -- Rob Kam (talk) 09:37, 19 December 2013 (UTC)Reply[reply]

Deleted 20:05, 23 March 2014‎ by Qgil - Not an appropriate possible project, see Bug 56388. -- Rob Kam (talk) 20:18, 17 July 2014 (UTC)Reply[reply]

Love templates and design? :)[edit]

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 Wikimedian and thought some people here might be interested - if you apply, please include some info about your Wikimedia experience!)
heather walls (talk) 23:39, 19 February 2014 (UTC)Reply[reply]

Translation tags broke numbered lists?[edit]

The numbered lists at the end of this page lost sequence when the translation tags were put in.

Fixed it, no thanks to VE. 03:26, 18 July 2014 (UTC)Reply[reply]

Variable number of parameters[edit]

What is the best practice with the MediaWiki engine for handling a variable number of parameters? Google has failed me. See this section on WikiMedia for an example. FarmerBob12 (talk) 18:44, 18 August 2014 (UTC)Reply[reply]

Wp/bcc/Documentation subpage[edit]

Hello! I need to make a (Template:Documentation subpage[4])for Balochi language wiki test , but I cant fix it, I don't know which problem ,not working, please help me for fix it.Thanks a lot.

Ibrahim khashrowdi (talk) 22:26, 1 September 2014 (UTC)Reply[reply]

if two tittle are confusing, which template is used for that[edit]

--Arjunkmohan (talk) 12:13, 3 September 2014 (UTC)Reply[reply]

Section MediaWiki code[edit]

@Shirayuki: Section MediaWiki code where it says "Uncheck the box "Include only the current revision, not the full history"." this should say "Leave the box checked ...". Rob Kam (talk) 19:21, 3 November 2014 (UTC)Reply[reply]


@Shirayuki: There ought to be mention of how to comply with licensing when re-using templates. Rob Kam (talk) 19:23, 3 November 2014 (UTC)Reply[reply]

How to make a template[edit]


This is the template I need help with

We use this template to call the image of a item to a page. Example here

Is there a way to make the item name a link that visitor's can click ?

For example: {{Item|Weapon enchant dust}} the item name Weapon enchant dust would be a link to the page Weapon enchant dust. Aleshyia (talk) 16:04, 30 November 2014 (UTC)Reply[reply]

If page identifies any parameter by number or name then anonymous method will no longer be available?[edit]

The article states:

Note: identifying parameters by order (with {{{1}}}, etc) works only with anonymous parameters. If your page identifies any parameter by number or name, as shown below, this method will no longer be available to the template which receives them.

However, this seems incorrect. If a parameter is named or numbered it is skipped as an anonymous position. For example, {{templatefoo|2=two|3=three|one}} would pass 'one' as parameter 1 (having skipped numbered parameters '2=two' and '3=three'). More examples at my userpage templatesandbox. Jonpatterns (talk) 11:49, 24 June 2016 (UTC)Reply[reply]

add an images that was uploaded trough a form[edit]

I've been looking for a way to add an images that was uploaded trough a form to show up in the #ask query, BUT I want to resize it.

I am not able to figure this out. Can anyone please help.

Embedding a template's page content[edit]

Hello. Is it possible to embed a template's <noinclude> content on another page? Like, embedding the contents as it appears on the actual "Template:" page, not when it's transluded normally. Thank you. 19:54, 25 October 2016 (UTC)Reply[reply]

Evalutaing template transclusion[edit]

I have templates of the form:

{{ template_name }}

I can get the code of the template page easily enough, but I would like to get only the template data that appears on the page that it is transcluded on, not all of the code in the template page. Is this possible?

Any help is appreciated

List of pages where template is using[edit]

How can I get pages where template was used? For example, I can get all pages, where file was used. Can I do something for get that information for templates? — Preceding unsigned comment added by (talk) 5 May 2017

Each template page should provide a link to "What links here" just like any other wiki page. It's a little confusing, but the list even distinguishes between transclusions of the template and regular wikilinks to it (example: Special:WhatLinksHere/Template:Navbar). - dcljr (talk) 01:29, 21 October 2017 (UTC)Reply[reply]

Linking to a template[edit]

The section on "Linking to a template" says this can be done by using a template named "tl". Using "{{tl|Example}}" – where "Example" is the name of the template – one gets "{{Example}}" with "Example" as a link and the curly braces as plain text. This might not be what one wants. Perhaps it should be added that you can also use "[[template:Example]]" to get the string "template:Example" as a link or "[[template:Example|Example]]" yielding "Example" as a link, in either case without the curly braces. Perhaps it's just my lack of imagination, but I can't really see why one would want the link displayed in curly braces.

Henryfunk (talk) 00:45, 20 October 2017 (UTC)Reply[reply]

Showing links to templates like {{this}} is a convenient way to show editors how they would actually use (i.e., call) such templates in wiki pages. It is a common convention on Wikimedia projects (e.g., in template documentation or on talk pages). Of course, if you are referring to the template itself as a wiki page (e.g., "see Template:This"), then linking to it like any other page is fine. I've tried to completely rewrite that section. Improvements are welcome, of course. - dcljr (talk) 01:20, 21 October 2017 (UTC)Reply[reply]

Template name when transcluded[edit]

Can a transcluded template know about its name? For example to generate a link to itself? --Ahmad Gharbeia أحمد غربية (talk) 20:45, 3 January 2018 (UTC)Reply[reply]

I'm not sure I understand your question. Any transcluded content must be stored under some page name. For a template to link to itself, you would just link to the page name that you are editing when you are creating the template. For example, if you are editing the template page "Template:Here", then the name of the template is "Template:Here", and you would link to the template itself by using [[Template:Here]]. - dcljr (talk) 12:34, 23 January 2018 (UTC)Reply[reply]

Remove template limitation[edit]

I really need to create a page that contains more than 115 templates. I have a wiki where one of the pages is the list of all the matches in my club. There are more than five thousand matches, divided into seasons from 1904 to 2018. I have a page for each season, but I need to use the templates so that when it is changed on the page of the season, it automatically changes on the page of all matches. If anyone knows how to remove the template limitation, it would help me a lot. Here is the page mentioned: (

When I try to use a large number of templates the following message appears: Warning: Template include size is too large. Some templates will not be included--ClicGrêmio (talk) 12:15, 23 January 2018 (UTC)Reply[reply]

Who knows a solution to this problem? -- 14:40, 17 July 2018 (UTC)Reply[reply]

  • The maximum include size is the $wgMaxArticleSize * 1024. Unmodified, that gives a 2MB maximum size. You can modify that setting, or you can reduce the number and/or size of templates. See the wikipedia help. --Clump (talk) 15:07, 17 July 2018 (UTC)Reply[reply]

Find out whether template is being transcluded from another template[edit]

Is it possible to find out whether a template is being transcluded directly in a page or via an intermediary template that is also eventually transcluded in a page?

By that I do not mean whether template is being transcluded in a page in the "template:" namespace.

--Ahmad Gharbeia أحمد غربية (talk) 00:36, 19 April 2018 (UTC)Reply[reply]

Categories on a Template in transcluded sub pages[edit]

Confusing situation but here it is. I have a template, that automatically selects the category for what type of page it is (Category:References and Category:Clarifications). The template then is used on two subpages (name/References and name/Clarifications) Those sub pages are transcluded onto the main page in various places. What I am wondering is is there a way to make the Template automatically include the category (as it does already) and NOT have that transcluded all the way to the main page? (the second level transclusion, after the use of the template on a subpage)

Thanks Lynkfox (talk) 13:28, 28 June 2018 (UTC)Reply[reply]

@Lynkfox: I don't think so, but Project:Support desk is the place to ask this kind of "product support" question. - dcljr (talk) 22:57, 28 June 2018 (UTC)Reply[reply]
Thanks. I ended up kludging together something by making pseudo magic words for < and > in order to make the <noinclude> not be processed as wiki commands until the 2nd transclusion. Lynkfox (talk) 12:57, 3 July 2018 (UTC)Reply[reply]

Export a table made with a template to join data[edit]

Good morning,

I created a table with a lot of columns thanks to a template. I used this template to join data from different pages, thus it contains many different {{#ask:}}. I only found how to export each {{#ask}} when I actually want to export the entire table. Does anyone have a solution for me? Thank you in advance. AnaisBce (talk) 07:49, 31 August 2018 (UTC)Reply[reply]

What languages are written in the Templates?[edit]


I would like to write my own Templates.

What should I know?

What languages are written in the Templates?


Sokote zaman (talk) 19:22, 11 September 2018 (UTC)Reply[reply]

They are written in standard MediaMarkup

--Squeak24 (talk) 15:29, 11 October 2018 (UTC)Reply[reply]

Parameter names with spaces[edit]

The paragraph on named template parameters includes no examples of parameter names that contain spaces. I would not use parameter names like "the parameter". I would use "theParameter" (or similar) instead, but is MediaWiki supposed to work with parameters that have spaces in their names? As of version 1.30 it accepts such parameters. Is this by design?

Henryfunk (talk) 07:24, 11 October 2018 (UTC)Reply[reply]

Special:Templates missing page[edit]

Hi, I hope all is well with you all.

I have a number of Wikis on the same server, but I have just come across a bit of an issue with my top level Wiki.

I was writing up how to create templates, but when I go to Special Pages I notice on this particular Wiki that the templates special page isn't there. It is on every other Wiki I have, just not this one.

I did try and get Visual Editor working on this Wiki to no avail (I am on a server that's not internet facing and had issues installing restBase and Parsoid). I am using TinyMCE, that is the only extension I have installed that is not part of the standard installation. However, I do have TinyMCE installed on another Wiki and it is working OK.

Any help is appreciated.

Squeak24 (talk) 11:05, 11 October 2018 (UTC)Reply[reply]

Borders of my Templates charts aren't working[edit]

I imported my templates from the Coppermind wiki, I'm only creating this wiki as a private notebook, but when I imported the chart templates the borders for them are not working. I don't know enough about php, or any other programming language, for that matter to build the templates on my own and I don't know what is wrong. The text is the same, except for the links that I'm changing to be my own, and I think I got all the other nessesary templates, but it is still not working. On one of the templates that I imported over the border did work. Also the charts that are supposed to be on the right side of the page are not.

A solution to the lack of template bundling.[edit]

A solution to the lack of template bundling has been proposed at Meta:Community Wishlist Survey 2019/Miscellaneous/Shared Multilingual Templates and Modules available to all wikis, please support it. --Rob Kam (talk) 09:16, 21 November 2018 (UTC)Reply[reply]

That's off-topic and not a solution but more like hacky maintenance hell. It is simply naive to believe that moving templates from one wiki to another will fix anything. For starters, templates often have local dependencies, they tend to link to local files and pages, and lastly because of the crazy way mediawiki works (e.g. {{ifexist / {{PAGESIZE}} et al.), it will start flooding small wikis with lots of WantedPages nonsense that the wiki doesn't want or need. Also, just because a template is accessible it doesn't mean it will work, for instance some wikis have certain extensions installed or parser functions that aren't available elsewhere and will break spectacularly. There is also the fact that wikitext itself depends on language and wiki specific aspects like linktrail .

If the only goal is to pick useful templates to be imported to third party wikis. Then this is better solved by finding simple templates, storing them on a central wiki (like this one), and creating a page explaining how to export them, e.g. [5]. 10:02, 21 November 2018 (UTC)

Added Wikipedia tables[edit]

inserting template for limited time[edit]


Is there any way to include a template to a page only for limited time only? In other words, how to schedule time-period when template is active for given page? I would like to display template with announcements that have exact start-day and end-day. I imagine i could add a template (or maybe section in worst case) on exact day but do not want to keep a record of what template to which page was added to remove them later, just want to set end-day in advance.

looking for any calendar mechanism, extension, job, anything, but no luck. 2A01:110F:142F:1500:8026:311F:9E33:56C0 14:48, 29 December 2020 (UTC)Reply[reply]

Evaluation order[edit]

If a page contains several templates:

  1. Are the templates defined to be evaluated in any specific order?
  2. Is there any way to set/store a value in one template and get/load it in another template?

I am assuming No and No, but just asking to be sure — GhostInTheMachine talk to me 23:29, 21 January 2021 (UTC)Reply[reply]

Youtube Template[edit]

Hi! I'm trying to use a template in such a way that when I put the YouTube video ID it shows the video in a frame.

The template goes like this:


In the template editing page:

<div class="thumb tright" style="width:310px;"> <youtube width="300" height="200">{{{1}}}</youtube> </div>

But when I refresh the article page, it shows the symbol of YouTube but can't play the video. It shows that there was a problem playing the video. What can I do to make it work? ThanksCampylobacter (talk) 19:44, 20 November 2021 (UTC)Reply[reply]

Why not simply use the <youtube> tag like in the following example?
<youtube>D_3LQjZgdbQ</youtube> Ulf Dunkel (talk) 07:54, 8 June 2023 (UTC)Reply[reply]

Using an unnamed parameter refuses to work[edit]

So my code is the following:
[[File:{{{1}}}_{{{2}}}.png|16px|link={{{1}}}#{{{2}}}|{{{2}}}]] [[{{{1}}}#{{{2}}}|{{{2}}}]]
The last {{{2}}} refuses to work. Replacing it with {{{1}}} makes the text show, but not the intended text. Could anyone tell me why this is happening? 416Eclipse (talk) 10:06, 18 March 2022 (UTC)Reply[reply]

Works for me --Ciencia Al Poder (talk) 12:10, 18 March 2022 (UTC)Reply[reply]

Question about naming conflicts when combining and Module:* and Template:* pages[edit]

Comparing Module:* Template:* in to, there are currently 1,035 naming conflicts. For example, Template:LL, for localized link (MediaWiki) / language link/in lang (Wikipedia). I will use Translate extension on my MediaWiki site (like uses), and I want to make sure not to create any page name conflicts. Has this topic been discussed previously somewhere? I'm trying to figure out best approach (preferably scripted) to identify pages that are duplicates/redundant. For example Template:Yesno (Wikipedia). After reducing the list to nonduplicates, I can use my best judgment which source to use for which name. I see 20 pages have docs including "Shared Template Warning" template stating "This page is shared between multiple wikis," however that does not appear a reliable indicator of redundancy, since some of these pages have altered modifications. Jasonkhanlar (talk) 05:48, 28 March 2022 (UTC)Reply[reply]

"Long" text inside parameter[edit]

In my wiki I have a template that auto crates the first lines of biographies based on parameters. This for the "XX was a scientist born in..." part. After that first lineof text I have a parameter called description,"that adds a bit more of information about the person. For example, "First man on the moon." Usually the description is very short, but recently I dealt with this historical figure that required more than that. So, his description was three short paragraphs. Mediawiki didn't like this.

The first description paragraph is no problem because it continues the line with the birth info. But to break to a second paragraph, I have to do it twice before it shows on preview or after being saved. And it shows larger than a normal break or


So, this code...

|descripcion=Paéz fue uno de los próceres más destacados de la guerra de Independencia, presidente de Venezuela en tres ocasiones y uno de los principales representantes del caudillismo americano. Entre otros apodos, se le conoció como "El centauro de los llanos", "El león de Payara", "El Catire" y "El Taita". 

Se destacó en numerosas batallas, entre ellas la Mata de la Miel (febrero 1816), las Queseras del Medio (abril 1819) y la batalla de Carabobo (junio, 1821). Dirigió la comisión para repatriar el cuerpo de Simón Bolívar desde Colombia. En 1826 encabezó el movimiento de la Cosiata, rebelión en contra del ejecutivo de la Gran Colombia que produjo su separación en naciones independientes. 

Debido a esto, su legado militar ha sido empañado por lo que algunos historiadores consideran traición contra el proyecto de gran nación sudamericana de Simón Bolívar. Padre de los pintores Ramón Páez y Carmelo Fernández Páez.

...shows as this...

Paéz fue uno de los próceres más destacados de la guerra de Independencia, presidente de Venezuela en tres ocasiones y uno de los principales representantes del caudillismo americano. Entre otros apodos, se le conoció como "El centauro de los llanos", "El león de Payara", "El Catire" y "El Taita".
Se destacó en numerosas batallas, entre ellas la Mata de la Miel (febrero 1816), las Queseras del Medio (abril 1819) y la batalla de Carabobo (junio, 1821). Dirigió la comisión para repatriar el cuerpo de Simón Bolívar desde Colombia. En 1826 encabezó el movimiento de la Cosiata, rebelión en contra del ejecutivo de la Gran Colombia que produjo su separación en naciones independientes.

Debido a esto, su legado militar ha sido empañado por lo que algunos historiadores consideran traición contra el proyecto de gran nación sudamericana de Simón Bolívar. Padre de los pintores Ramón Páez y Carmelo Fernández Páez. Sus restos reposan en el Panteón Nacional desde el 19 abril de 1888.

...rather than this...

Paéz fue uno de los próceres más destacados de la guerra de Independencia, presidente de Venezuela en tres ocasiones y uno de los principales representantes del caudillismo americano. Entre otros apodos, se le conoció como "El centauro de los llanos", "El león de Payara", "El Catire" y "El Taita".

Se destacó en numerosas batallas, entre ellas la Mata de la Miel (febrero 1816), las Queseras del Medio (abril 1819) y la batalla de Carabobo (junio, 1821). Dirigió la comisión para repatriar el cuerpo de Simón Bolívar desde Colombia. En 1826 encabezó el movimiento de la Cosiata, rebelión en contra del ejecutivo de la Gran Colombia que produjo su separación en naciones independientes.

Debido a esto, su legado militar ha sido empañado por lo que algunos historiadores consideran traición contra el proyecto de gran nación sudamericana de Simón Bolívar. Padre de los pintores Ramón Páez y Carmelo Fernández Páez. Sus restos reposan en el Panteón Nacional desde el 19 abril de 1888.

Any clues on this behavior? You can see the thing live in this link. José Antonio Páez. Cojoilustrado 07:01, 4 November 2022 (UTC)

Have you tried starting the parameter value on a new line, rather than immediately after the equals sign? That is, like this:
Paéz fue uno de...
I'm not sure this would work since the transcluded text begins mid-paragraph, but it's worth a try. Alternatively, you could use "<p>" elements everywhere you want a regular paragraph break (instead of blank lines). I think that should make them all look the same. (BTW, I wonder what the benefit could be of passing paragraphs of text through a template like this. IOW, why not just make the template responsible for forming only the first sentence? The subsequent sentences/paragraphs of text can immediately follow the template call. This should avoid the issue of inconsistent paragraph breaks.) - dcljr (talk) 20:09, 4 November 2022 (UTC)Reply[reply]

Using external_data extension in a template[edit]

I have an Infobox-template, that i want to fill with info from a CSV file that has the same name as the page that is using the template. However, i don’t see the correct data on the page, rather the default values i set, when the csv is empty. For now i have only been able to make this work from the template-using page directly. how would i go about this correctly? template: Template:Infobox VM; page using template: Host:somehost; csv file somehost.csv — Preceding unsigned comment added by (talkcontribs) 4 January 2023

Please ask this at Extension talk:External Data (per Extension:External Data/Getting support). - dcljr (talk) 00:14, 6 January 2023 (UTC)Reply[reply]

What is the easiest way to use both uppercase and lowercase parameters?[edit]

In some older templates, I have used parameter names starting with an uppercase letter. Of course I could do the following steps to chance them to lowercase:

  1. add the relevant lowercase parameter sections in my templates; or
  2. chance the relevant uppercase parameters to lowercase and edit all relevant articles where the template has been used

While 1) is the easier way (and makes the template still work for old pages) I still wonder if there is any easier way then implementing both spellings like this:

{{#if: {{{Name|}}} | {{{Name}}} }}{{#if: {{{name|}}} | {{{name|}}} }} Ulf Dunkel (talk) 08:10, 8 June 2023 (UTC)Reply[reply]