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: [[Media:|]] . Now without a defined param2 it should work like this: [[Media:|]] . --Subfader 09:57, 28 March 2008 (UTC)
 * Got it now! Thanks. --Subfader 18:31, 10 April 2008 (UTC)

A parameter starting with a single "+" sign is not processed as expected
I wrote a template where a parameter holds a telephone number (its content looks like "+123 (456) 78901234"). If I type something like this: It's not processed correctly and the value is displayed on the wrong position. If I type something like this: 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)
 * Please tell us what the template definition looks like -- Duesentrieb ⇌ 12:30, 31 March 2008 (UTC)
 * This is a really simple template used to display business card info within a table:


 * ––Major² 23:59, 31 March 2008 (UTC)

[RESOLVED] replace paramter if ...
Parameters: I use (desc) to create a link to desc page of 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)

Included Titles Cannot Be Edited by Subsection
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:


 * Members:
 * Topic:
 * 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)


 * 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   magic word.
 * You could disable edit link of a particular section by making it not a real heading, so instead of  === ===  just do something like   
 * You could leave an explanatory note to be seen by anyone editing template definition, using HTML comments. Something like:  * Members:  
 * I appreciate non of these things offer an ideal solution for you. Anyone else have suggestions?
 * -- Harry Wood 10:11, 1 May 2008 (UTC)


 * No, unfortunately not. But I have exactly the same problem.--Gollum 16:09, 15 May 2008 (UTC)
 * 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 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)

Choosing between templates on the same page
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)