MediaWiki: Infobox Values when added to template
I've read a bunch of information on mediawiki's site regarding the creation of templates. I've also implemented my own templates. My only issue is, I have a template that has an infobox tied to it. Whenever I add a new item to the infobox, I want it to reflect on ALL pages that have the template tied to it, whether or not I have defied it in the page that uses the template. I need it to have a default value. So, basically, when I add something to the infobox, each page that uses this template, will automatically see it on the infobox as "default" until they insert their own value in. Is this possible, or is this something that templates on mediawiki cannot do?
My main question is: How do you include a mediawiki template and have it sh开发者_运维知识库ow everything, including the undefined variables? This is useful, for instance, if new data is added to the template, but isn't "filled in" yet and this would be an indicator that the data needs to be inserted.
UPDATE 10/14/2011 @ 3:30PM CST:
Here's the actual template (called Template:EmployeeInfo):{{Infobox
|name = {{{name}}}
|title = {{{title}}}
}}
And the way I include it (page is called "Employee Drew"):
{{EmployeeInfo
|name = Drew
|title = My Title
}}
Now...what if I were to add something to the template, for instance, now the template looks like this:
{{Infobox
|name = {{{name}}}
|title = {{{title}}}
|education = {{{education}}}
}}
How would I get every page that includes Template:EmployeeInfo to include the "education" section, even if the page "Employee Drew" (and other pages) only have the name and title variables defined?
I take it that your Template:Infobox is testing that the variable is empty and not displaying the field? The easiest way is to just specify a default value for the education variable in your Template:EmployeeInfo:
{{Infobox
|name = {{{name}}}
|title = {{{title}}}
|education = {{{education|default value}}}
}}
You can use the ParserFunctions extension to test whether the {{{education}}} variable is empty or not and fill the infobox with anything if it is.
{{Infobox
|name = {{{name}}}
|title = {{{title}}}
|education = {{#if: {{{education}}} | {{{education}}} | N/A}}
}}
This is old but someone might find it useful. For undefined parameters you can define defaults in the template.
For example: {{{name|no name}}}
In this case, if parameter "name" is not defined, the template will output "no name".
https://www.mediawiki.org/wiki/Help:Templates#Default_values
精彩评论