Help talk:Templates

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.

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)

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)

Templates with/for images
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.


 * assign the parameter ( ImageName:= )
 * expand this to [[Image:[[ImageName:=]]|150px|]]

Unfortunately like this it doesn't work. 85.125.230.177 15:53, 13 June 2007 (UTC)

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)

Some help?
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 [] installed and working. Then you can do the following; Give that a try and let us know if you got it working =)
 * Rank:
 * Rank:

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.

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

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 template: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: '*', ';', '='... (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.

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.

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)

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

Thank You stnick @ wikiwood