Help talk:Templates

Templates not refreshing
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  to the end of the URL. See Manual:Purge for details.

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

Namespaces
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)

I did see that mentioned someplace just a second ago. Martin | talk • contribs 22:13, 22 February 2007 (UTC)

Pass Variable into Hidden Section Header
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:
and for it to come out as Header: variable

When I attempt to use, it comes out as Header: 

The xh4 tags I'm using come from here: https://meta.wikimedia.org/wiki/Help:Section#Making_a_heading_that_does_not_show_up_in_ToC

How can I accomplish this?

Confused
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

Re:Confused
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 www.yourdomain.com/wiki/Template:first Write there something like: Your first argument: Your second argument:

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, from template page will be replaced with everything what is after 1=

--Betlista 17:53, 17 May 2007 (UTC)

where should i place this image
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
At my wiki I have a template called Shape and a template called R strange. The original intention was to put inside the Shape template, but writing  doesn't work, rather it makes it be interpreted as. Is there any way to nest templates like this?

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

- Keiji 82.32.169.78 16:37, 18 June 2007 (UTC)

Never mind, I got it to work.

- Keiji 82.32.169.78 16:57, 18 June 2007 (UTC)
 * How??? Slamlander 05:31, 25 October 2007 (UTC)
 * It seems to be impossible, also below. JackPotte 06:33, 16 August 2010 (UTC)

[Resolved] Why will a table row's text output in bold?
Can anyone explain to me why this code produces bold text? I can't figure it out. Thanks in advance.

--67.84.103.128 00:38, 24 June 2007 (UTC)


 * 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)
 * Thanks a lot for the help, but why is it that a ! instead of a | makes it bold? --67.84.103.128 01:15, 24 June 2007 (UTC)
 * See Help:Tables. -- :Bdk: 01:42, 24 June 2007 (UTC)
 * 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. --67.84.103.128 02:02, 24 June 2007 (UTC)

Default templates?
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) 165.219.245.62 19:12, 10 July 2007 (UTC)
 * 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)

Quick installer, perhaps?
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?
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.

First, make sure you have the parser functions m:Help:ParserFunctions installed and working. Then you can do the following; Give that a try and let us know if you got it working =)
 * Rank:
 * Rank:
 * Thank you for mentioning this ParserFunctions extension, a lot of wasted time until I found that, thanks!

Infobox class??
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)
 * I'm not a PHP programmer, but this line doesn't look right in monobook.php -


 * /*<![CDATA[*/ @import "text('stylepath') ?>/text('stylename') ?>/main.css?"; /*]]>*/
 * --DJS68 02:29, 1 September 2007 (UTC)
 * nope that's not the problem :-( --DJS68 02:37, 1 September 2007 (UTC)

Templates Outside the Template Namespace
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:
 * 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:
 * 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.


 * That's called transclusion. --Thnidu (talk) 02:06, 13 September 2012 (UTC)

Template Migration
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)
 * Use Special:Export and Special:Import. Or you could try remote transclusion. Jlerner 18:45, 16 November 2007 (UTC)

Templates Args
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 } 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)

Template Overload
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, 79.193.229.90 15:28, 24 January 2008 (UTC)

How do the Wikipedia Template: Cite book and Template: Cite work?
I'd like this in conjunction with my wiki page... but currently I can't figure out the implementation.--66.214.128.163 17:08, 2 February 2008 (UTC)


 * 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:
 *  , , ,  .  


 * ...to 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)

[RESOLVED] Missing parameter
Let's say i define 2 parameters. When only 1 is called it will display. Is there a way to let it fall back to and call in such cases? --Subfader 20:04, 29 February 2008 (UTC)
 * --Egingell 16:44, 1 March 2008 (UTC)
 * Ok how to add it? I have the template:  has not been replaced by the template engine. The html source code is:

False 

I suppose thats through the " " 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

Path This works just fine until I try to insert the path via template. The result looks like this  instead of http://example.com/file.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: {{#widget:Iframe ... 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.
 * url=

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

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

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)

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

Ada Programming/Delimiters/

However, some invocations work (e.g. with &</tt>, '</tt>, +</tt>...), but others don't (e.g. *</tt>, ;</tt>, :</tt>...). In the cases that don't work directly, sometimes it works using the HTML entity (e.g. &amp;#42;</tt> for *</tt>), sometimes when using the named parameter ( </tt> for '/=' delimiter). Can I write something in the switch for not havin to use the HTML entity or the named parameter? Thanks! &mdash;surue&ntilde;a 23:03, 29 December 2008 (UTC)


 * Done, I've just to remove the default case. Of course, for those delimiters containing a '=' named parameter should be used ( </tt> for '/=' delimiter), and the html number (&amp;#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! &mdash;surue&ntilde;a 12:34, 30 December 2008 (UTC)


 * 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 &mdash;surue&ntilde;a 12:54, 30 December 2008 (UTC)
 * What does the pipe symbol do? I see some logic using  and some using  (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)

Unknown Number of Variables beforehand
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?

Thanks.


 * One way I've seen this done is by creating a template that takes lots of optional parameters.   </tt> can be used to include/exclude each part depending on if that parameter is specified.  For example, in Template:Infobox the parameters   </tt> to   </tt> 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)


 * 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 installed and working.
 * --Thnidu (talk) 02:17, 13 September 2012 (UTC)

Heading level and templates
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)
 * Top header
 * = Second level header ={{{h|==}}
 * It's not pretty, but it works and makes sense.
 * WilliamsJD 21:01, 31 January 2012 (UTC)
 * WilliamsJD 21:01, 31 January 2012 (UTC)

Remove braced variables from article?
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 displayed in the article that included the template. Correct? If so, just give the parameter an empty default value in the template. Use  rather than  when referencing the parameter in the template. --Vjg 16:03, 9 March 2009 (UTC)
 * 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)

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

Thank You stnick @ wikiwood 


 * 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)

Blank Default Parameters
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,, 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!

-Michelle


 * Use (notice the pipe character after the "1"). INVERTED 20:41, 25 July 2009 (UTC)


 * It sounds like what you want is  </tt> Servel333 (talk) 16:52, 16 July 2012 (UTC)

Wiki equals HTML
This is an example of an wiki format. 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)


 * 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)

Calling a Template on every Site
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).

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

A simple "how to" or tutorial section
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
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)

I Am UTTERLY Thick
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)

Cheadings and other Special Characters passed in as a template param
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.

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) 
 * 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.

</tt>
 * to

<tt>
 * for

</tt>
 * and allows the asterisk to be correctly interpreted:


 * and


 * This last example looks a bit messy, though, so it might not fit your purpose. Hamilton Abreu 14:02, 5 February 2010 (UTC)


 * 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)
 * Kjoz, adding a line break, followed by a new line, is a valid workaround: Hamilton Abreu 14:02, 5 February 2010 (UTC)

Template Above Title - and possible lock
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.
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: Your second argument:

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)

[RESOLVED] Defining parameters
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 "=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)


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

Source code of the page has &amp;lt;tr&amp;gt;&amp;lt;th&amp;gt; instead &lt;tr&gt;&lt;th&gt;
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 <th class="mbox-text" style="text-align:left; padding:1px;">Файл:Stock post message.svg To-do list for Шаблон:Todo: <td class="mbox-empty-cell"> 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=" t-todo" style="border-collapse:separate; " cellspacing="4" <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: http://vazia.no-ip.org/

Sorry for bad English :) —VaZia 21:35, 22 February 2010 (UTC)
 * 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)
 * I did not found any red links in the bottom of .--VaZia 21:32, 23 February 2010 (UTC)
 * 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)
 * 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
 * &amp;lt;tr&amp;gt;&amp;lt;th class="mbox-text" style="text-align:left; padding:1px;"&amp;gt; I saw it in FireBug. That is why pure html tags
 * <th class="mbox-text" style="text-align:left; padding:1px;">Файл:Stock post message.svg To-do list for Шаблон:Todo: <td class="mbox-empty-cell">
 * appears on the http://vazia.no-ip.org/index.php/Template:Todo page.--VaZia 21:32, 23 February 2010 (UTC)


 * Yes, you're right about CSS not being the cause. It seems that your wiki is not allowing the use of the <tt>&lt;tr&gt;</tt> and <tt>&lt;th&gt;</tt> HTML tags, although in principle they should be allowed. Check {{meta|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
 * <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 <tt>|</tt> before the <tt> {{ </tt>) should produce the adequate <tt>&lt;tr&gt;</tt> and <tt>&lt;th&gt;</tt> HTML tags in the output instead of <tt>&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;</tt>. 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 <tt>&lt;tr&gt;</tt> and <tt>&lt;th&gt;</tt> 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)
 * Hamilton Abreu, thank you for your attention! Yes, template can be fixed by using |-,|,! instead <tt>&lt;tr&gt;,&lt;td&gt;,&lt;th&gt;</tt> 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 <tt>&lt;tr&gt;</tt> and <tt>&lt;th&gt;</tt> HTML tags? Now, I found the related link and will go there --VaZia 09:20, 24 February 2010 (UTC)

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

But the template does:

takes over you can no longer do parameter substitution. Maybe we've finally found what the  magic word can be used for. If you replace the template by:

<pre style="margin-left:25px">{{#tag:gallery| File:{{{File1}}}{{!}}{{{Desc1}}} }}
 * 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)


 * Tried this and it almost worked for me. How do you pass along information like width and perrow? 108.16.87.29 21:53, 2 July 2011 (UTC)


 * Nevermind! Had a ephiany and got it - piped in after content instead of before. 108.16.87.29 21:57, 2 July 2011 (UTC)

<pre style="margin-left:25px">{{#tag:gallery| File:{{{File1}}}{{!}}{{{Desc1}}} }}
 * widths="100px"|perrow="3"


 * Correct. You can also pass them in:

<pre style="margin-left:100px">{{#tag:gallery| File:{{{File1}}}{{!}}{{{Desc1}}} File:{{{File2}}}{{!}}{{{Desc2}}} }}
 * widths={{{Widths}}}
 * perrow={{{Perrow}}}
 * Hamilton Abreu 12:57, 3 July 2011 (UTC)

what does this mean?
I was wondering if anyone could explain what does the following tag does? Thank you, Bud0011 18:35, 17 October 2010 (UTC).


 * It prevents trimming:


 * gives pr,


 * also at the start and end of a template.--Patrick 11:43, 18 October 2010 (UTC)
 * Cool. And thank you. Bud0011 16:32, 18 October 2010 (UTC).

Template Problems
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).
 * 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)

import templates
Following the instructions of the article, I could create few templates. Especially I am interested in the. 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)
 * 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)

Template Naming Conventions
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).

Preventing a nested noinclude from breaking your template in version 1.12.0
[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:

&lt;noinclude&gt;Pear&lt;nowiki&gt;&lt;noinclude&gt;Banana&lt;/noinclude&gt;&lt;/nowiki&gt;Apple&lt;/noinclude&gt; 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: &lt;noinclude&gt;Pear&lt;nowiki&gt;&amp;lt;noinclude&amp;gt;Banana&amp;lt;/noinclude&amp;gt;Apple&lt;/nowiki&gt;&lt;/noinclude&gt;

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?
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)
 * 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. hugs,
 * 2. then, what file is "includes/Parser.php"?
 * 3. next, "includes/parser/Parser.php" has this code as line 3278.


 * 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).


 * 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)


 * Thanks! Badon 02:53, 9 August 2011 (UTC)


 * If you are using a conditional parser function, the pipe helps to test if the parameter exists. For example:

If a template is called with a parameter like 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. 169.253.194.1 19:36, 17 July 2012 (UTC)

Link table doesn't contain links from templates
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.--84.196.119.55 09:34, 21 October 2011 (UTC)

Importing Wikipedia Templates
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)

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

The "If you don't have import rights on the new wiki:" section
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)

usage of "substitute"
Under Usage, I'm changing the first sentence of the entry for  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.

to
 * 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 or Imagine this paragraph in a cookbook:
 * "replace X" = remove X (and put something else in its place)
 * "substitute X" = (remove something and) put X in its place
 * 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)

Equals sign as a parameter
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: Hope this will come in handy.
 * includes > parser > Preprocessor_DOM.php
 * Search for:
 * Put false instead of true on the next line

Problem
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

Example with a table (not-working)

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

Solution
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.

http://en.wikipedia.org/wiki/Help:Template#Usage_hints_and_workarounds

http://www.mediawiki.org/wiki/Help:Magic_words#Other

Template for ASCII-art
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  tag, but this tag does not appear to work with templates.

I create a template called and I would like to pass it some ASCII-art, and have it formatted as: <pre style="font: 125% monospace; border:none; background:#FFFFFF;">

However, when I use the template like this:

or

I want the result to be:

<pre style="font: 125% monospace; border:none; background:#FFFFFF;">:)

But the result is:

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


 * 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)


 * 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 becoming a variable, it instead outputs a literal . 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)

Having Some Trouble Getting A Parameter's Default Value To Work
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, but I would prefer the cleaner method.

Template disabling on Embedded page
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
I have a 'list_items' template that does the following:

Mr has

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?
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 wikia.com site, which runs some version of mediawiki)

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

Please support request for templates for new MediaWiki installs
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)
 * 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)

Love templates and design? :)
We have a paid wiki-design contract position with the Wikimedia Foundation: We need your help making it easier for Wikimedians to participate in the movement and with each other!
 * Travel and Participation Support Grants is looking for someone to help design and build a new portal on meta-wiki to make this grants program easier to navigate and more fun to use. You'd be working with me, to make something suitable for this program that fits with other grants pages on meta-wiki. We’d prefer someone with wiki and template knowledge (this would outweigh other experience). Please see the job description for details, pass it along to anyone you know, and feel free to ask me or Siko if you have any questions. We look forward to speaking with you!
 * (We’re posting around the community because we’d love to hire a 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)

Translation tags broke numbered lists?
The numbered lists at the end of this page lost sequence when the translation tags were put in. https://www.mediawiki.org/w/index.php?title=Help%3ATemplates&diff=966443&oldid=966442


 * Fixed it, no thanks to VE. 124.181.193.145 03:26, 18 July 2014 (UTC)

Variable number of parameters
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)

Wp/bcc/Documentation subpage
Hello! I need to make a (Template:Documentation subpage)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)

if two tittle are confusing, which template is used for that
--Arjunkmohan (talk) 12:13, 3 September 2014 (UTC)

Section MediaWiki code
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)

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

How to make a template
Hi

This is the template I need help with http://ds.irowiki.org/wiki/Template:Item

We use this template to call the image of a item to a page. Example here http://ds.irowiki.org/wiki/Consumables

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

For example: the item name Weapon enchant dust would be a link to the page Weapon enchant dust. Aleshyia (talk) 16:04, 30 November 2014 (UTC)