Help talk:Template
From Wikipedia, the free encyclopedia
[edit] Template tip section on my user page
I have noticed that less experienced users might notice that I create a lot of templates for my own use (see User:Will Pittenger/templates for a list). Those users might try to ask for a fix to their template (or for creation of a template they don't know how to start) on my talk page. In an attempt to encourage them to seek the correct locations, I wrote User:Will Pittenger#Tips on working with templates.
Does anyone see any changes I should make? I am not attempting to provide a complete tutorial; just explain common mistakes. Will (Talk - contribs) 08:26, 15 February 2007 (UTC)
- It looks good. You might want to think about harmonizing it with {{Template doc page transcluded}} and {{Sample}}.
[edit] If-then
I skimmed/searched the article, but couldn't find anything to help me - is it possible to tell a template to look for an inputted value and if the value matches a predefined value, give a specific output? Specifically, I want to make a template (on another wiki) that puts a page in the Build: namespace in one of five (seven?) categories, but they're named quite differently. I was thinking I could make it so that if I say {{Build|Stub}}, the template would show that the page is a stub and add the page to Category:Stubs, whereas if I put in {{Build|New}}, it would add it to Category:New builds. (Note that these would entail different templates combined into one.) The biggest problem would be getting the code to put it in different percentage categories; we want the pages to be categorized by percentage, and the categories will be 0-19%, 20-39%, etc. Can I make it so that if I say {{build|0}} it'll put it in Category:0-19% builds, {{build|20}} in Category:20-39% builds, and so forth? While I have your attention, is it possible for a template to spit out the time it was placed on a page? I've tried messing with ~~~~~, nowiki tags around certain areas of the code (which just disabled the code until it got to an end tag), and {{CURRENTTIME}}, but nothing's helped.
Thank you for your help! -- Maethon (talk) 21:39, 10 May 2007 (UTC)
[edit] Template X2
The page transcludes {{X2}} which on m:Help:Template works fine but here it's a sandbox template. Jɪmp 01:33, 28 May 2007 (UTC)
[edit] Usage
In the section on usage it states "Templates are useful for any text for which one wants a copy in two or more pages, and there is no need for each copy to be edited independently to adapt it to the page it is in." In the recent deletion debate [here http://en.wikipedia.org/wiki/Wikipedia:Templates_for_deletion/Log/2007_August_29#Template:La_Martiniere_Song here] it was noted in particular that "Templates should not masquerade as article content in the main article namespace; instead, place the text directly into the article." I wonder if it might be advisable to change the wording of the usage section here because, in view of this deledtion debate the text as it currently stands is misleading and implies that it is acceptable to use templates for editorial text. Either that or the WP:TMP guideline should be changed. Dahliarose 15:29, 6 September 2007 (UTC)
- The text is general for all MediaWiki wikis, except the section Wikipedia-specific help. The latter can be used for Wikipedia policy.--Patrick 16:36, 6 September 2007 (UTC)
- Sorry I hadn't realised that was the case. Thanks for explaining. Dahliarose 19:48, 6 September 2007 (UTC)
[edit] Simpler, clearer explanations needed
Hi, I think this Help article is not really of much help to beginners at all. It uses far too much jargon and doesn't explain clearly how to use parameters or special operators such as #if and #switch. Is there another article that does this? If not, would somebody please simplify this article? Cheers, Jacklee 01:34, 19 September 2007 (UTC)
- At the top it says: For an introduction, see A quick guide to templates and mw:Help:Templates.--Patrick 10:01, 19 September 2007 (UTC)
Yes, but those articles are too simple and don't explain the use of functions such as #if and #switch, which I see being used in other templates. What is needed is an article that explains in more detail the workings of templates, but with clearer examples and without the jargon. I am trying to create a template to display a link to an online version of the Singapore Constitution with the syntax "{{Singapore Constitution|full=|rep=}}" (see {{Singapore Constitution}}, which doesn't work properly at the moment). The purpose of the "full" parameter, which is intended to take a "yes" or "no" value, is for users to indicate whether they would like the full title of the Constitution ("Constitution of the Republic of Singapore") or an abbreviated title ("Singapore Constitution") to be displayed. However, I can't determine from this help article how to do so, or whether this can even be done. Cheers, Jacklee 12:18, 19 September 2007 (UTC)
- That has little to do with templates: use #ifeq instead of #if.--Patrick 14:13, 19 September 2007 (UTC)
But surely that has everything to do with templates! How do I find out how to use #ifeq instead of #if? What does #ifeq even mean? Is there a full list of operators that begin with # somewhere, with instructions on how they should be used? This underlines my point that there needs to be a clear article somewhere explaining how all this works, otherwise there are just going to be a lot of broken templates out there. Cheers, Jacklee 14:22, 19 September 2007 (UTC)
- See m:Help:ParserFunctions. It is linked from this help page.--Patrick 14:31, 19 September 2007 (UTC)
Oh, right. I didn't even realize those were called parser functions. Thanks. Anyway, I hope you look into my feedback about clarifying and simplifying this article. Cheers, Jacklee 05:28, 20 September 2007 (UTC)
- I agree. I already understand these things a bit, but wanted a little clarification since one of my template additions is not behaving, and I left more confused than when i came.--Esprit15d( • ۞ • ▲) 13:28, 8 November 2007 (UTC)
[edit] passing a table
I am setting up templates for a wiki we are establishing where i work. We are using the templates because many people will be contributing and we want to keep a consistency throughout the pages. The template is used to establish section headers with data being passed to populate the text under the section.
One of the sections contains a table.. when the table is passed to a variable it shows up as simply an opening curly bracket, nothing else in its contents appears.
I've found references to double curly brackets being passed but nothing saying that a single would cause problems.
Can anyone tell me if it is possible to pass a table as a variable and if so, what i am doing wrong?
The code i am using for the template is as follows:
==Section 1 Header==
{{{data0|}}}
==Section 2 Header==
{{{data1|}}}
==Section 3 Header==
{{{data2|}}}
==Section 4 Header==
{{{data3|}}}
==Section 5 Header==
{{{data4|}}}
==Section 6 Header==
{{{data5|}}}
==Section 7 Header==
{{{data6|}}}
The page that calls the template contains the following:
{{Design Review|data6=
{|
|-
|Test
|}
}}
Caile13 21:13, 12 November 2007 (UTC)
- Encode the "|" of the table syntax as "{{!}}", see Template:! (backlinks, edit).--Patrick 00:20, 13 November 2007 (UTC)
Ok.. i found the page you are talking about but it appears to reference anther template that, since we are using our own instantiation of a wiki, we don't currently have. i was going to try to build it but when i try to view source... things get really confusing. am i correct in thinking that i need to set up a special template to get the {{!}} to work in place of "|" ? Caile13 15:02, 13 November 2007 (UTC)
- Yes, but it only needs to contain "|", the rest is documentation.--Patrick 00:53, 14 November 2007 (UTC)
[edit] Categories and templates
I'm having some trouble with categories and templates. There are some templates on Eurovision pages that automatically categorize any page with the template in a certain category. The problem is that it is the wrong category. How do i add something or change something in these templates to make the pages who have them be in the right category? I also want to add some categorizers to some templates. For example, I want all pages having this template [1] to be in Category:Sweden in the Eurovision Song ContestGrk1011 (talk) 22:32, 19 January 2008 (UTC)
[edit] Lanlp 1 defunct?
Template:Lanlp 1 is given as an example of repitition, and indeed that is the case on meta, but the wikipedia version is just a URL as of October. What's the correct thing to do? jhawkinson (talk) 14:33, 25 January 2008 (UTC)
[edit] WPSI Template help
There is an annoying glitch with the comments section of Template:WPSI. Sorry if I am being dense, but can someone tell me how I can find some technical help with this? Thanks. Ben MacDuiTalk/Walk 12:12, 30 March 2008 (UTC)
[edit] Plural if more than one parameter
I need a way to change a word in a template to plural if more than one parameter is passed. Does anyone know how I would do this? Any ideas? Kaldari (talk) 19:01, 16 April 2008 (UTC)
- If you are using parameters the normal way (not named) so they come in as numbered parameters, then you can do as they do over at the {{shortcut}} template:
Shortcut{{#if:{{{2|}}}|s}}
- Which renders "Shortcut" if only one parameter and "Shortcuts" if two or more parameters.
- --David Göthberg (talk) 00:02, 17 April 2008 (UTC)
[edit] Starting a parameter value with an asterisk
Whenever I start a parameter value with an asterisk, it is not formatted as a list item. It's not converted at all. Surely there's a way to have lists passed in as parameter values? See here as an example -- Charles (Kznf) (talk) 14:36, 2 May 2008 (UTC)
- Bullet markup must be in the first column. You need a break before the first line. I added one for you. --— Gadget850 (Ed) talk - 15:19, 2 May 2008 (UTC)
-
- Of course it does! I'm an idiot. Thank you. Charles (Kznf) (talk) 20:15, 2 May 2008 (UTC)
-
- You are welcome --— Gadget850 (Ed) talk - 21:03, 2 May 2008 (UTC)
[edit] Problems with the new WikiProject Soviet Union template
In an effort to improve WikiProject Soviet Union, I have undertaken a task over the past few days to lay the groundwork for an improved project template by adding class= and importance= parameters to the templates on the talk pages of each article in the scope of the project. After this was completed, I attempted to modify the template (using Template:WP conlangs as a guide - the new template is essentially a clone of it - it is also important to note that the WP conlangs template works flawlessly) so it would display the newly-embedded information and sort the tagged articles into categories based on class and importance. While the modified template looked good with both class= and importance= left blank (i.e. the way it appeared in the template page itself, which has now been moved to a sandbox on my user page), all talk pages to which the new template had been attached to appeared strangely deformed, with certain parameters outside the template's space. In general, it was simply messing up the talk page. The sandbox, and the attached doc file, are exact copies of the faulty, new WP Soviet Union template. The template itself has been reverted to its previous state, but its history still contains the faulty version. If anyone can help me in resolving this project or helping me find someone who can help, your assistance would be greatly appreciated. Thanks! TFCforever (talk) 22:51, 3 June 2008 (UTC)
- Replied on user talk page. Just some trouble with noinclude tags. JackSchmidt (talk) 01:42, 4 June 2008 (UTC)

