Help talk:Templates
|
|
Note: This page is for discussion of the Help:Templates page only. General software questions or requests for help should be posted on the Support Desk. |
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.
[edit] 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)
[edit] 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?
{{Object
|name=
|image=
|filename=
|Developer=
|Latest=
|Release=
|License=
}}
Thats what I put for a test template and all i get is the title come up Object
Any ideas
[edit] 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:<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:
{{first|1=text1|2=text2}}
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)
[edit] 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
[[File:picture01.png|150px|]]
?
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.
[[File:{{{ImageFILENAME}}}|150px]]
As long as you follow the appropriate formatting syntax, you should be fine.
[edit] Templates inside parameters
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 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)
[edit] [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.
{|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.
|}
--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)
- See Help:Tables. --:Bdk: 01:42, 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)
[edit] 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)
[edit] 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
[edit] 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.
{| 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)
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!
[edit] 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 -
- <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)
- nope that's not the problem :-( --DJS68 02:37, 1 September 2007 (UTC)
[edit] 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
importexpand this pageintoon whatever page you were editing.
-
{{Help_talk:Templates}}- A special addition needs to be made if you are trying to use a page from the "(Main)" namespace since a call to:
-
{{Main_page}} - is equivalent to a call to:
-
{{Template:Main_page}} - 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:
-
{{:Main_page}}
My apologies if this has already been discussed elsewhere. --Egingell (talk) 20:58, 2 September 2007 (UTC)
[edit] 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)
[edit] 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 {{{ {{#var:{{i}} }} }}}} to manufacture a "argv[]/argc" was the best I can come up with, but it seems to be a pretty intensive.
{{mytemplate|namedParam=1
|unnamedOne
|unnamedTwo
|unanmedThree
|...
}}
Thanks --Gmillerd 10:44, 26 November 2007 (UTC)
[edit] 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)
[edit] 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:
- <span id="{{{ref}}}" name="{{{ref}}}" class="citation">{{{author}}}, ''{{{title}}}'', [[{{{publisher}}}]], [[{{{date}}}]].</span>
- ...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)
[edit] [RESOLVED] Missing parameter
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)
-
{{#if:{{{param2|}}}|{{{param2}}}|{{{param1}}}}}--Egingell 16:44, 1 March 2008 (UTC)
[edit] 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:
{{TemplateName
|Phone=+123 (456) 78901234
}}
It's not processed correctly and the value is displayed on the wrong position. If I type something like this:
{{TemplateName
|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)
- 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:
{|cellspacing="1"
|-
! 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
|{{{Phone}}}
|}
-
- ––Major² 23:59, 31 March 2008 (UTC)
[edit] [RESOLVED] replace paramter if ...
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)
[edit] 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:
=== {{{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)
- 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)
-
- 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 __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)
- No, unfortunately not. But I have exactly the same problem.--Gollum 16:09, 15 May 2008 (UTC)
[edit] 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)
Did you ever happen to solve this problem? I am looking to accomplish the same thing!
[edit] input tag filled with a template value
Hi,
Is there any way to display input tag filled with template values within a page?
Example:
<td>
[[Delivery::{{{Delivery|}}}]]
<html><input type="checkbox" checked="[[Delivery::{{{Delivery|}}}]]" disabled></html>
</td>
"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:
<td>
False
<input type="checkbox" checked="[[Delivery::{{{Delivery|}}}]]" disabled>
</td>
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
[edit] Templates inside parameters
Hi, I'd like in my wiki a structure like:
{{detailedDescription
|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)
[edit] Special characters as template parameters
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|}}}
|.=dot
|..=double dot
||=vertical line
|=>=arrow
|>==greater than or equal to
|<==less than or equal to
|#default = {{{1}}}
}}|{{{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. * 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)
- 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 (|) 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)
-
- 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)
- 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)
- 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)
[edit] 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.
[edit] 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|h====}}
- (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)
[edit] 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 {{{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)
- 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)
[edit] Documentation Page
Where do you place the Documentation Page? namespace:Template:Info Box xxx
Thank You stnick @ wikiwood [1]
[edit] 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, [[{{{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!
-Michelle
- Use {{{Subcategory 1|}}} (notice the pipe character after the "1"). INVERTED 20:41, 25 July 2009 (UTC)
[edit] Wiki equals HTML
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)
- 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)
[edit] 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).
[edit] 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: {{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.--66.92.234.13 04:33, 8 June 2009 (UTC)
[edit] 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
[edit] 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)
[edit] 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)
[edit] 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.
{{Thankyou
|reason=*all your hard work and
*great looks
|signature=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)
- 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}}}}}}.
-
-
- to
-
-
- for
- {{{reason|{{{1}}}}}}.
-
-
- and allows the asterisk to be correctly interpreted:
{{User:Hamilton Abreu/testes/Thank you
|reason=*all your hard work and
*great looks
|signature=Joe}}
-
- and
{{User:Hamilton Abreu/testes/Thank you
|reason=dinner and
*desert
|signature=Joe}}
-
- 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)
{{Thankyou
|reason=<br />
*all your hard work and
*great looks
|signature=Joe}}
[edit] 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.
[edit] 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:{{{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)
[edit] 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 "{{{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)
[edit] Source code of the page has <tr><th> instead <tr><th>
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
<tr><th></th></tr>
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: 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)
- 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
-
<tr><th class="mbox-text" style="text-align:left; padding:1px;">
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 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 <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 <tr><th>. 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)
- 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)
-
-
-
-
-
- Do you know HTML? It strikes me that the usual way to define a table would be:
<table> <tr> <th></th> <th></th> </tr> <tr> <td></td> <td></td> </tr> </table>But the template does:
<table> <tr> <th></th> <td></td> </tr> ...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)
- Do you know HTML? It strikes me that the usual way to define a table would be:
-
-
-
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)
- Thanks for that, Phcalle. -- Hamilton Abreu 04:28, 2 April 2011 (UTC)
[edit] Searchable template content?
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)
- 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)
- 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)
[edit] Space delimiter in external links causing issue in template.
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|http://www.google.com/search?q={{{tutorial-description|{{PAGENAME}}}}}}}}
{{{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
Example:
{{Tutorial/General|tutorial-description=µTorrent|url=http://www.utorrent.com|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
{{Tutorial/General}}
it parses to
This is a general tutorial about Foo Bar. For further information see Bar Foo Bar on Google.
With link
http://www.google.com/search?q=Foo
Any help greatly appreciated. --Kharay1977 19:48, 19 July 2010 (UTC)
- 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)
- 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)
[edit] Using another page or template as parameters?
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 24.10.151.126 (talk • contribs) 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)
[edit] Is there any script to create sub template in a template
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)
- Templates inside parameter values are allowed: {{t1|{{tc}}}} gives startinend.--Patrick 00:09, 20 August 2010 (UTC)
- 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)
[edit] Gallery In a Template
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.
Template:MyGallery
<gallery>
File:{{{File1}}}|{{{Desc1}}}
</gallery>
Page:
{{MyGallery
| 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)
- 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:
{{#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)
-
{{#tag:gallery|
File:{{{File1}}}{{!}}{{{Desc1}}}
|widths="100px"|perrow="3"
}}
-
-
-
- Correct. You can also pass them in:
-
-
{{#tag:gallery|
File:{{{File1}}}{{!}}{{{Desc1}}}
File:{{{File2}}}{{!}}{{{Desc2}}}
|widths={{{Widths}}}
|perrow={{{Perrow}}}
}}
-
-
-
- Hamilton Abreu 12:57, 3 July 2011 (UTC)
-
-
[edit] what does this mean?
I was wondering if anyone could explain what does the following tag does? <nowiki/> Thank you, Bud0011 18:35, 17 October 2010 (UTC).
- It prevents trimming:
-
p{{#if:x|<nowiki/> q <nowiki/>}}rgives p q r,
- 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).
[edit] 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)
[edit] import templates
Following the instructions of the article, I could create few templates. Especially I am interested in the Template:Cite journal. 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)
[edit] 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).
[edit] 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:
<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:
<noinclude>Pear<nowiki><noinclude>Banana</noinclude>Apple</nowiki></noinclude>
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.
[edit] 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?:
{{{Parameter|}}}
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 {{{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).
-
- 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)
-
[edit] 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)
[edit] 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)
[edit] Whitespace nightmare
There needs to be a section devoted to dealing with whitespace in templates. Badon 08:27, 13 December 2011 (UTC)
[edit] 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)