Help talk:Templates

From mediawiki.org
Latest comment: 1 month ago by Ciencia Al Poder in topic Pass in arbitrary XML as value for a parameter

Templates not refreshing[edit]

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 ?action=purge to the end of the URL. See Manual:Purge for details.

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

Namespaces[edit]

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)Reply
I did see that mentioned someplace just a second ago. Martin | talkcontribs 22:13, 22 February 2007 (UTC)Reply

Pass Variable into Hidden Section Header[edit]

I'd like to be able to pass a variable into a section header that is to be hidden from the TOC, like so:

<xh4>

====Header: {{{1}}}====

</xh4>

and for it to come out as Header: variable

When I attempt to use {{TemplateName|variable}}, it comes out as Header: {{{1}}}

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[edit]

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

Re:Confused[edit]

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

Templates with/for images[edit]

where should i place this image[edit]

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

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

Templates inside parameters[edit]

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

Never mind, I got it to work.

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

How??? Slamlander 05:31, 25 October 2007 (UTC)Reply
It seems to be impossible, also below. JackPotte 06:33, 16 August 2010 (UTC)Reply

[Resolved] Why will a table row's text output in bold?[edit]

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

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)Reply
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)Reply
See Help:Tables. --:Bdk: 01:42, 24 June 2007 (UTC)Reply
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)Reply

Default templates?[edit]

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

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

Quick installer, perhaps?[edit]

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?[edit]

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

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!

Infobox class??[edit]

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

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)Reply
nope that's not the problem :-( --DJS68 02:37, 1 September 2007 (UTC)Reply

Templates Outside the Template Namespace[edit]

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.
{{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)Reply

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

Template Migration[edit]

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

Templates Args[edit]

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

Template Overload[edit]

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

How do the Wikipedia Template: Cite book and Template: Cite work?[edit]

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


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

[RESOLVED] Missing parameter[edit]

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

{{#if:{{{param2|}}}|{{{param2}}}|{{{param1}}}}}
--Egingell 16:44, 1 March 2008 (UTC)Reply
Ok how to add it? I have the template: [[Media:{{{1}}}|{{{2}}}]]. Now without a defined param2 it should work like this: [[Media:{{{1}}}|{{{1}}}]]. --Subfader 09:57, 28 March 2008 (UTC)Reply
Got it now! Thanks. --Subfader 18:31, 10 April 2008 (UTC)Reply

A parameter starting with a single "+" sign is not processed as expected[edit]

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

Please tell us what the template definition looks like -- Duesentrieb 12:30, 31 March 2008 (UTC)Reply
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)Reply

[RESOLVED] replace paramter if ...[edit]

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

Included Titles Cannot Be Edited by Subsection[edit]

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

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

Choosing between templates on the same page[edit]

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


Did you ever happen to solve this problem? I am looking to accomplish the same thing!

input tag filled with a template value[edit]

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


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
<pdf width="800" heigth="800">Path</pdf>

This works just fine until I try to insert the path via template. The result looks like this

<pdf width="800" heigth="800">{{{Path|}}}</pdf>
instead of
<pdf width="800" heigth="800">http://example.com/file.pdf</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
|url={{{Path|}}}
...

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.

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

One possible solution is to use the parserfunction #tag instead. This is a wrapper which can be used on every tag available. See meta:Help:XML-style_tags#Tag_function. --Mglaser (talk) 09:23, 13 October 2016 (UTC)Reply

This worked for me[edit]

Apparently, the HTML tags are not really acting as HTML tags. They are instead telling the parser (not the browser) how to render the text to follow. So, you can simply throw in an end tag where ever, put in the variable, and restart the html again.

<html></nowiki><br>
Blah blah, then an end tag before you insert a variable,<br> 
</html>
<br>
{{variable_name}}
<br>
<html>
<br>and any additional text.
<br><nowiki>
</html>

Templates inside parameters[edit]

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

Special characters as template parameters[edit]

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
  |&#124;=vertical line
  |&#61;>=arrow
  |>&#61;=greater than or equal to
  |<&#61;=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. &#42; 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)Reply

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 (&#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! —surueña 12:34, 30 December 2008 (UTC)Reply
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)Reply
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)Reply

Unknown Number of Variables beforehand[edit]

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. {{#if: {{{PARAM|}}} | {{{PARAM}}} }} can be used to include/exclude each part depending on if that parameter is specified. For example, in Template:Infobox the parameters {{{data1}}} to {{{data80}}} 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)Reply
#if: 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#Installation installed and working.
--Thnidu (talk) 02:17, 13 September 2012 (UTC)Reply

Heading level and templates[edit]

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

Remove braced variables from article?[edit]

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

Documentation Page[edit]

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

Thank You stnick @ wikiwood [1]

Include the following within the template page:
   <noinclude>{{tempdoc}}</noinclude>
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)Reply
I use to place the documentation in '''Template:Template name/Docu''', which is Template:Info Box xxx/Docu in your example. Ulf Dunkel (talk) 07:41, 8 June 2023 (UTC)Reply

Blank Default Parameters[edit]

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)Reply
It sounds like what you want is {{#if: {{{Subcategory 1|}}} | [[{{{Subcategory 1}}}]] }} Servel333 (talk) 16:52, 16 July 2012 (UTC)Reply

Wiki equals HTML[edit]

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

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

Calling a Template on every Site[edit]

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).Reply
I guess you mean how to display a template on every page of your wiki, right? Here's a how to. You need access to your LocalSettings.php file on the server:
Display template on every page Ulf Dunkel (talk) 07:46, 8 June 2023 (UTC)Reply

Unclear behavior of template substitution[edit]

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

A simple "how to" or tutorial section[edit]

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[edit]

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

I Am UTTERLY Thick[edit]

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

Cheadings and other Special Characters passed in as a template param[edit]

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}}


A little thank you... for *all your hard work and

  • great looks.

hugs, 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)Reply

  • 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:
Example sunflower image
Example sunflower image
A little thank you...
for
  • all your hard work and
  • great looks.
    hugs, Joe
{{User:Hamilton Abreu/testes/Thank you
|reason=*all your hard work and
*great looks
|signature=Joe}}
and
Example sunflower image
Example sunflower image
A little thank you...
for

dinner and

  • desert.
    hugs, Joe
{{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)Reply

A little thank you... for

  • all your hard work and
  • great looks.

hugs, Joe

{{Thankyou
|reason=<br />
*all your hard work and
*great looks
|signature=Joe}}

Template Above Title - and possible lock[edit]

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.[edit]

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

[RESOLVED] Defining parameters[edit]

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

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

Source code of the page has &lt;tr&gt;&lt;th&gt; instead <tr><th>[edit]

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

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)Reply
I did not found any red links in the bottom of [2].--VaZia 21:32, 23 February 2010 (UTC)Reply
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)Reply
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
&lt;tr&gt;&lt;th class="mbox-text" style="text-align:left; padding:1px;"&gt;
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)Reply
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 &lt;tr&gt;&lt;th&gt;. 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)Reply
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)Reply

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

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

Thanks for that, Phcalle. -- Hamilton Abreu 04:28, 2 April 2011 (UTC)Reply

Searchable template content?[edit]

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

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

Space delimiter in external links causing issue in template.[edit]

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

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

Using another page or template as parameters?[edit]

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 (talkcontribs) 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)Reply

Is there any script to create sub template in a template[edit]

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)Reply
Templates inside parameter values are allowed: {{t1|{{tc}}}} gives startinend.--Patrick 00:09, 20 August 2010 (UTC)Reply
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)Reply

Gallery In a Template[edit]

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

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)Reply
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)Reply
Nevermind! Had a ephiany and got it - piped in after content instead of before. 108.16.87.29 21:57, 2 July 2011 (UTC)Reply
{{#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)Reply

what does this mean?[edit]

I was wondering if anyone could explain what does the following tag does? <nowiki/> Thank you, Bud0011 18:35, 17 October 2010 (UTC).Reply

It prevents trimming:
p{{#if:x|<nowiki> q <nowiki/>}}r gives p q r,
also at the start and end of a template.--Patrick 11:43, 18 October 2010 (UTC)Reply
Cool. And thank you. Bud0011 16:32, 18 October 2010 (UTC).Reply

Template Problems[edit]

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

import templates[edit]

Following the instructions of the article, I could create few templates. Especially I am interested in the {{cite journal| title=Where to get it?}}. 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)Reply

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

Template Naming Conventions[edit]

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).Reply
In general, wiki template pages are just pages, but in the special Template: namespace. Name them like you would name article pages. Ulf Dunkel (talk) 07:50, 8 June 2023 (UTC)Reply

Preventing a nested noinclude from breaking your template in version 1.12.0[edit]

[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>&lt;noinclude&gt;Banana&lt;/noinclude&gt;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.

Documentation of parameters themselves nonexistent - what does a pipe do at the end of a parameter?[edit]

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

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).Reply
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)Reply
Thanks! Badon 02:53, 9 August 2011 (UTC)Reply
If you are using a conditional parser function, the pipe helps to test if the parameter exists. For example:

{{#if:{{{1|}}}|display this}} If a template is called with a parameter like {{Mytemplate|MyParameter}} 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)Reply

Link table doesn't contain links from templates[edit]

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

Importing Wikipedia Templates[edit]

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

Whitespace nightmare[edit]

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

  • I second this! (wish I knew the answer to put here)
    • It may be related to [3]

The "If you don't have import rights on the new wiki:" section[edit]

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

usage of "substitute"[edit]

Under Usage, I'm changing the first sentence of the entry for {{subst:Name}} 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

  • "replace X" = remove X (and put something else in its place)

or

  • "substitute X" = (remove something and) put X in its place

Imagine this paragraph in a cookbook:

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

Equals sign as a parameter[edit]

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:

  • includes > parser > Preprocessor_DOM.php
  • Search for:
} elseif ( $found == 'pipe' ) {
  • Put false instead of true on the next line

Hope this will come in handy.

[SOLVED] Table as Parameter[edit]

Problem[edit]

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

Template with some arbitrary wiki code as content

  • list item 1
  • list item 2

http://www.wikipedia.org


Example with a table (not-working)

Template with table wiki code as content

{

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

Solution[edit]

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[edit]

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

I create a template called {{ascii}} and I would like to pass it some ASCII-art, and have it formatted as:

<pre style="font: 125% monospace; border:none; background:#FFFFFF;">{{{1}}}</pre>

However, when I use the template like this:

{{ascii| :) }}

or

{{ascii|1= :) }}

I want the result to be:

:)

But the result is:

{{{1}}}

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

    • 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 {{{1}}} becoming a variable, it instead outputs a literal {{{1}}}. 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)Reply

Having Some Trouble Getting A Parameter's Default Value To Work[edit]

I have a template with a parameter of

{{{name}}}

. I want the default value of the parameter name to be "none". So I added

{{{name|none}}}

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 none, but I would prefer the cleaner method.

Template disabling on Embedded page[edit]

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[edit]

I have a 'list_items' template that does the following:

Mr {{{NAME}}} has

  • {{{items}}}


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?[edit]

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[edit]

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 (talkcontribs) 23:04, 25 November 2006.

Please support request for templates for new MediaWiki installs[edit]

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

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

Love templates and design? :)[edit]

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

Translation tags broke numbered lists?[edit]

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

Variable number of parameters[edit]

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

Wp/bcc/Documentation subpage[edit]

Hello! I need to make a (Template:Documentation subpage[4])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)Reply

if two tittle are confusing, which template is used for that[edit]

--Arjunkmohan (talk) 12:13, 3 September 2014 (UTC)Reply

Section MediaWiki code[edit]

@Shirayuki: 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)Reply

Licensing[edit]

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

How to make a template[edit]

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: {{Item|Weapon enchant dust}} the item name Weapon enchant dust would be a link to the page Weapon enchant dust. Aleshyia (talk) 16:04, 30 November 2014 (UTC)Reply

If page identifies any parameter by number or name then anonymous method will no longer be available?[edit]

The article states:

Note: identifying parameters by order (with {{{1}}}, etc) works only with anonymous parameters. If your page identifies any parameter by number or name, as shown below, this method will no longer be available to the template which receives them.

However, this seems incorrect. If a parameter is named or numbered it is skipped as an anonymous position. For example, {{templatefoo|2=two|3=three|one}} would pass 'one' as parameter 1 (having skipped numbered parameters '2=two' and '3=three'). More examples at my userpage templatesandbox. Jonpatterns (talk) 11:49, 24 June 2016 (UTC)Reply

add an images that was uploaded trough a form[edit]

I've been looking for a way to add an images that was uploaded trough a form to show up in the #ask query, BUT I want to resize it.

I am not able to figure this out. Can anyone please help.

Embedding a template's page content[edit]

Hello. Is it possible to embed a template's <noinclude> content on another page? Like, embedding the contents as it appears on the actual "Template:" page, not when it's transluded normally. Thank you.

79.40.29.157 19:54, 25 October 2016 (UTC)Reply

Evalutaing template transclusion[edit]

I have templates of the form:


{{ template_name }}

I can get the code of the template page easily enough, but I would like to get only the template data that appears on the page that it is transcluded on, not all of the code in the template page. Is this possible?

Any help is appreciated

List of pages where template is using[edit]

How can I get pages where template was used? For example, I can get all pages, where file was used. Can I do something for get that information for templates? — Preceding unsigned comment added by 89.250.18.4 (talk) 5 May 2017

Each template page should provide a link to "What links here" just like any other wiki page. It's a little confusing, but the list even distinguishes between transclusions of the template and regular wikilinks to it (example: Special:WhatLinksHere/Template:Navbar). - dcljr (talk) 01:29, 21 October 2017 (UTC)Reply

Linking to a template[edit]

The section on "Linking to a template" says this can be done by using a template named "tl". Using "{{tl|Example}}" – where "Example" is the name of the template – one gets "{{Example}}" with "Example" as a link and the curly braces as plain text. This might not be what one wants. Perhaps it should be added that you can also use "[[template:Example]]" to get the string "template:Example" as a link or "[[template:Example|Example]]" yielding "Example" as a link, in either case without the curly braces. Perhaps it's just my lack of imagination, but I can't really see why one would want the link displayed in curly braces.

Henryfunk (talk) 00:45, 20 October 2017 (UTC)Reply

Showing links to templates like {{this}} is a convenient way to show editors how they would actually use (i.e., call) such templates in wiki pages. It is a common convention on Wikimedia projects (e.g., in template documentation or on talk pages). Of course, if you are referring to the template itself as a wiki page (e.g., "see Template:This"), then linking to it like any other page is fine. I've tried to completely rewrite that section. Improvements are welcome, of course. - dcljr (talk) 01:20, 21 October 2017 (UTC)Reply

Template name when transcluded[edit]

Can a transcluded template know about its name? For example to generate a link to itself? --Ahmad Gharbeia أحمد غربية (talk) 20:45, 3 January 2018 (UTC)Reply

I'm not sure I understand your question. Any transcluded content must be stored under some page name. For a template to link to itself, you would just link to the page name that you are editing when you are creating the template. For example, if you are editing the template page "Template:Here", then the name of the template is "Template:Here", and you would link to the template itself by using [[Template:Here]]. - dcljr (talk) 12:34, 23 January 2018 (UTC)Reply

Remove template limitation[edit]

I really need to create a page that contains more than 115 templates. I have a wiki where one of the pages is the list of all the matches in my club. There are more than five thousand matches, divided into seasons from 1904 to 2018. I have a page for each season, but I need to use the templates so that when it is changed on the page of the season, it automatically changes on the page of all matches. If anyone knows how to remove the template limitation, it would help me a lot. Here is the page mentioned: (http://www.gremiopedia.com/wiki/Todos_os_jogos_na_hist%C3%B3ria_do_Gr%C3%AAmio)

When I try to use a large number of templates the following message appears: Warning: Template include size is too large. Some templates will not be included--ClicGrêmio (talk) 12:15, 23 January 2018 (UTC)Reply

Who knows a solution to this problem? --168.195.85.99 14:40, 17 July 2018 (UTC)Reply

Find out whether template is being transcluded from another template[edit]

Is it possible to find out whether a template is being transcluded directly in a page or via an intermediary template that is also eventually transcluded in a page?

By that I do not mean whether template is being transcluded in a page in the "template:" namespace.

--Ahmad Gharbeia أحمد غربية (talk) 00:36, 19 April 2018 (UTC)Reply

Categories on a Template in transcluded sub pages[edit]

Confusing situation but here it is. I have a template, that automatically selects the category for what type of page it is (Category:References and Category:Clarifications). The template then is used on two subpages (name/References and name/Clarifications) Those sub pages are transcluded onto the main page in various places. What I am wondering is is there a way to make the Template automatically include the category (as it does already) and NOT have that transcluded all the way to the main page? (the second level transclusion, after the use of the template on a subpage)

Thanks Lynkfox (talk) 13:28, 28 June 2018 (UTC)Reply

@Lynkfox: I don't think so, but Project:Support desk is the place to ask this kind of "product support" question. - dcljr (talk) 22:57, 28 June 2018 (UTC)Reply
Thanks. I ended up kludging together something by making pseudo magic words for < and > in order to make the <noinclude> not be processed as wiki commands until the 2nd transclusion. Lynkfox (talk) 12:57, 3 July 2018 (UTC)Reply

Export a table made with a template to join data[edit]

Good morning,

I created a table with a lot of columns thanks to a template. I used this template to join data from different pages, thus it contains many different {{#ask:}}. I only found how to export each {{#ask}} when I actually want to export the entire table. Does anyone have a solution for me? Thank you in advance. AnaisBce (talk) 07:49, 31 August 2018 (UTC)Reply

What languages are written in the Templates?[edit]

Hello

I would like to write my own Templates.

What should I know?

What languages are written in the Templates?

Thanks

Sokote zaman (talk) 19:22, 11 September 2018 (UTC)Reply

They are written in standard MediaMarkup

--Squeak24 (talk) 15:29, 11 October 2018 (UTC)Reply

Parameter names with spaces[edit]

The paragraph on named template parameters includes no examples of parameter names that contain spaces. I would not use parameter names like "the parameter". I would use "theParameter" (or similar) instead, but is MediaWiki supposed to work with parameters that have spaces in their names? As of version 1.30 it accepts such parameters. Is this by design?

Henryfunk (talk) 07:24, 11 October 2018 (UTC)Reply

Special:Templates missing page[edit]

Hi, I hope all is well with you all.

I have a number of Wikis on the same server, but I have just come across a bit of an issue with my top level Wiki.

I was writing up how to create templates, but when I go to Special Pages I notice on this particular Wiki that the templates special page isn't there. It is on every other Wiki I have, just not this one.

I did try and get Visual Editor working on this Wiki to no avail (I am on a server that's not internet facing and had issues installing restBase and Parsoid). I am using TinyMCE, that is the only extension I have installed that is not part of the standard installation. However, I do have TinyMCE installed on another Wiki and it is working OK.

Any help is appreciated.

Squeak24 (talk) 11:05, 11 October 2018 (UTC)Reply

Borders of my Templates charts aren't working[edit]

I imported my templates from the Coppermind wiki, I'm only creating this wiki as a private notebook, but when I imported the chart templates the borders for them are not working. I don't know enough about php, or any other programming language, for that matter to build the templates on my own and I don't know what is wrong. The text is the same, except for the links that I'm changing to be my own, and I think I got all the other nessesary templates, but it is still not working. On one of the templates that I imported over the border did work. Also the charts that are supposed to be on the right side of the page are not.

A solution to the lack of template bundling.[edit]

A solution to the lack of template bundling has been proposed at Meta:Community Wishlist Survey 2019/Miscellaneous/Shared Multilingual Templates and Modules available to all wikis, please support it. --Rob Kam (talk) 09:16, 21 November 2018 (UTC)Reply

That's off-topic and not a solution but more like hacky maintenance hell. It is simply naive to believe that moving templates from one wiki to another will fix anything. For starters, templates often have local dependencies, they tend to link to local files and pages, and lastly because of the crazy way mediawiki works (e.g. {{ifexist / {{PAGESIZE}} et al.), it will start flooding small wikis with lots of WantedPages nonsense that the wiki doesn't want or need. Also, just because a template is accessible it doesn't mean it will work, for instance some wikis have certain extensions installed or parser functions that aren't available elsewhere and will break spectacularly. There is also the fact that wikitext itself depends on language and wiki specific aspects like linktrail .

If the only goal is to pick useful templates to be imported to third party wikis. Then this is better solved by finding simple templates, storing them on a central wiki (like this one), and creating a page explaining how to export them, e.g. [5]. 10:02, 21 November 2018 (UTC)

Added Wikipedia tables[edit]

inserting template for limited time[edit]

Hi,

Is there any way to include a template to a page only for limited time only? In other words, how to schedule time-period when template is active for given page? I would like to display template with announcements that have exact start-day and end-day. I imagine i could add a template (or maybe section in worst case) on exact day but do not want to keep a record of what template to which page was added to remove them later, just want to set end-day in advance.

looking for any calendar mechanism, extension, job, anything, but no luck. 2A01:110F:142F:1500:8026:311F:9E33:56C0 14:48, 29 December 2020 (UTC)Reply

Evaluation order[edit]

If a page contains several templates:

  1. Are the templates defined to be evaluated in any specific order?
  2. Is there any way to set/store a value in one template and get/load it in another template?

I am assuming No and No, but just asking to be sure — GhostInTheMachine talk to me 23:29, 21 January 2021 (UTC)Reply

Youtube Template[edit]

Hi! I'm trying to use a template in such a way that when I put the YouTube video ID it shows the video in a frame.

The template goes like this:

{{YoutubeVid|YoutubeID}}

In the template editing page:

<div class="thumb tright" style="width:310px;"> <youtube width="300" height="200">{{{1}}}</youtube> </div>

But when I refresh the article page, it shows the symbol of YouTube but can't play the video. It shows that there was a problem playing the video. What can I do to make it work? ThanksCampylobacter (talk) 19:44, 20 November 2021 (UTC)Reply

Why not simply use the <youtube> tag like in the following example?
<youtube>D_3LQjZgdbQ</youtube> Ulf Dunkel (talk) 07:54, 8 June 2023 (UTC)Reply

Using an unnamed parameter refuses to work[edit]

So my code is the following:
[[File:{{{1}}}_{{{2}}}.png|16px|link={{{1}}}#{{{2}}}|{{{2}}}]] [[{{{1}}}#{{{2}}}|{{{2}}}]]
The last {{{2}}} refuses to work. Replacing it with {{{1}}} makes the text show, but not the intended text. Could anyone tell me why this is happening? 416Eclipse (talk) 10:06, 18 March 2022 (UTC)Reply

Works for me --Ciencia Al Poder (talk) 12:10, 18 March 2022 (UTC)Reply

Question about naming conflicts when combining MediaWiki.org and Wikipedia.org Module:* and Template:* pages[edit]

Comparing Module:* Template:* in Mediawiki.org to Wikipedia.org, there are currently 1,035 naming conflicts. For example, Template:LL, for localized link (MediaWiki) / language link/in lang (Wikipedia). I will use Translate extension on my MediaWiki site (like Mediawiki.org uses), and I want to make sure not to create any page name conflicts. Has this topic been discussed previously somewhere? I'm trying to figure out best approach (preferably scripted) to identify pages that are duplicates/redundant. For example Template:Yesno (Wikipedia). After reducing the list to nonduplicates, I can use my best judgment which source to use for which name. I see 20 pages have docs including "Shared Template Warning" template stating "This page is shared between multiple wikis," however that does not appear a reliable indicator of redundancy, since some of these pages have altered modifications. Jasonkhanlar (talk) 05:48, 28 March 2022 (UTC)Reply

"Long" text inside parameter[edit]

In my wiki I have a template that auto crates the first lines of biographies based on parameters. This for the "XX was a scientist born in..." part. After that first lineof text I have a parameter called description,"that adds a bit more of information about the person. For example, "First man on the moon." Usually the description is very short, but recently I dealt with this historical figure that required more than that. So, his description was three short paragraphs. Mediawiki didn't like this.

The first description paragraph is no problem because it continues the line with the birth info. But to break to a second paragraph, I have to do it twice before it shows on preview or after being saved. And it shows larger than a normal break or

.

So, this code...

|descripcion=Paéz fue uno de los próceres más destacados de la guerra de Independencia, presidente de Venezuela en tres ocasiones y uno de los principales representantes del caudillismo americano. Entre otros apodos, se le conoció como "El centauro de los llanos", "El león de Payara", "El Catire" y "El Taita". 

Se destacó en numerosas batallas, entre ellas la Mata de la Miel (febrero 1816), las Queseras del Medio (abril 1819) y la batalla de Carabobo (junio, 1821). Dirigió la comisión para repatriar el cuerpo de Simón Bolívar desde Colombia. En 1826 encabezó el movimiento de la Cosiata, rebelión en contra del ejecutivo de la Gran Colombia que produjo su separación en naciones independientes. 

Debido a esto, su legado militar ha sido empañado por lo que algunos historiadores consideran traición contra el proyecto de gran nación sudamericana de Simón Bolívar. Padre de los pintores Ramón Páez y Carmelo Fernández Páez.

...shows as this...


Paéz fue uno de los próceres más destacados de la guerra de Independencia, presidente de Venezuela en tres ocasiones y uno de los principales representantes del caudillismo americano. Entre otros apodos, se le conoció como "El centauro de los llanos", "El león de Payara", "El Catire" y "El Taita".
Se destacó en numerosas batallas, entre ellas la Mata de la Miel (febrero 1816), las Queseras del Medio (abril 1819) y la batalla de Carabobo (junio, 1821). Dirigió la comisión para repatriar el cuerpo de Simón Bolívar desde Colombia. En 1826 encabezó el movimiento de la Cosiata, rebelión en contra del ejecutivo de la Gran Colombia que produjo su separación en naciones independientes.

Debido a esto, su legado militar ha sido empañado por lo que algunos historiadores consideran traición contra el proyecto de gran nación sudamericana de Simón Bolívar. Padre de los pintores Ramón Páez y Carmelo Fernández Páez. Sus restos reposan en el Panteón Nacional desde el 19 abril de 1888.


...rather than this...


Paéz fue uno de los próceres más destacados de la guerra de Independencia, presidente de Venezuela en tres ocasiones y uno de los principales representantes del caudillismo americano. Entre otros apodos, se le conoció como "El centauro de los llanos", "El león de Payara", "El Catire" y "El Taita".

Se destacó en numerosas batallas, entre ellas la Mata de la Miel (febrero 1816), las Queseras del Medio (abril 1819) y la batalla de Carabobo (junio, 1821). Dirigió la comisión para repatriar el cuerpo de Simón Bolívar desde Colombia. En 1826 encabezó el movimiento de la Cosiata, rebelión en contra del ejecutivo de la Gran Colombia que produjo su separación en naciones independientes.

Debido a esto, su legado militar ha sido empañado por lo que algunos historiadores consideran traición contra el proyecto de gran nación sudamericana de Simón Bolívar. Padre de los pintores Ramón Páez y Carmelo Fernández Páez. Sus restos reposan en el Panteón Nacional desde el 19 abril de 1888.

Any clues on this behavior? You can see the thing live in this link. José Antonio Páez. Cojoilustrado 07:01, 4 November 2022 (UTC)

Have you tried starting the parameter value on a new line, rather than immediately after the equals sign? That is, like this:
|descripcion=
Paéz fue uno de...
I'm not sure this would work since the transcluded text begins mid-paragraph, but it's worth a try. Alternatively, you could use "<p>" elements everywhere you want a regular paragraph break (instead of blank lines). I think that should make them all look the same. (BTW, I wonder what the benefit could be of passing paragraphs of text through a template like this. IOW, why not just make the template responsible for forming only the first sentence? The subsequent sentences/paragraphs of text can immediately follow the template call. This should avoid the issue of inconsistent paragraph breaks.) - dcljr (talk) 20:09, 4 November 2022 (UTC)Reply


Using external_data extension in a template[edit]

I have an Infobox-template, that i want to fill with info from a CSV file that has the same name as the page that is using the template. However, i don’t see the correct data on the page, rather the default values i set, when the csv is empty. For now i have only been able to make this work from the template-using page directly. how would i go about this correctly? template: Template:Infobox VM; page using template: Host:somehost; csv file somehost.csv — Preceding unsigned comment added by 24.134.95.253 (talkcontribs) 4 January 2023

Please ask this at Extension talk:External Data (per Extension:External Data/Getting support). - dcljr (talk) 00:14, 6 January 2023 (UTC)Reply

What is the easiest way to use both uppercase and lowercase parameters?[edit]

In some older templates, I have used parameter names starting with an uppercase letter. Of course I could do the following steps to chance them to lowercase:

  1. add the relevant lowercase parameter sections in my templates; or
  2. chance the relevant uppercase parameters to lowercase and edit all relevant articles where the template has been used

While 1) is the easier way (and makes the template still work for old pages) I still wonder if there is any easier way then implementing both spellings like this:

{{#if: {{{Name|}}} | {{{Name}}} }}{{#if: {{{name|}}} | {{{name|}}} }} Ulf Dunkel (talk) 08:10, 8 June 2023 (UTC)Reply

Pass in arbitrary XML as value for a parameter[edit]

I'm using the Fandom Wiki's extension to provide an XML-style infobox structure. I made a parent template that creates a rough infobox shape with some basic fields, and looks something like this:

<infobox>
  <data>
    <default>some value</default>
  </data>
  {{{more_data}}}
</infobox>

Now, I'm creating a child template that builds on this one. I would like to pass in a snippet of XML using these "data" tags to insert additional rows on the parent template. I tried using the #tag parser, but it renders its contents as plaintext, rather than interpreting as HTML, even with nested #tag parser functions.

{{Parent Template
| more_data = {{#tag:data|{{#tag:default|my value}}}}
}}

I can't find a nice way to represent this in text, but if you take {{#tag:data|{{#tag:default|my value}}}} and slap it on a page, it renders as <default>my value</default>-- e.g., the default tags inside get rendered as text content.

Tldr; For templating QOL reasons I would like to pass in XML as the content of a parameter to the template, and it doesn't work because the nested XML is not being processed as XML nodes. 13.110.54.42 01:35, 8 February 2024 (UTC)Reply

I'm pretty sure #tag only works for top-level extension functions, not with any arbitrary xml-style tag (for example, normal html tags). <data> tags are not provided by the infobox extension, it only provides <infobox>. Then, the inner tags are parsed internally by the extension, they're not processed by the parser. That's why I think it doesn't work, and you should feed the literal XML tags instead of using #tag. Ciencia Al Poder (talk) 10:35, 8 February 2024 (UTC)Reply