MediaWiki:添加到模板时的信息框值

发布于 2024-10-22 01:52:33 字数 931 浏览 1 评论 0原文

我在 mediawiki 网站上阅读了大量有关模板创建的信息。我还实现了自己的模板。我唯一的问题是,我有一个模板,其中绑定了一个信息框。每当我向信息框中添加新项目时,我希望它反映在所有与其关联的模板的页面上,无论我是否在使用该模板的页面中拒绝了它。我需要它有一个默认值。因此,基本上,当我向信息框中添加某些内容时,使用此模板的每个页面都会自动在信息框中将其视为“默认”,直到它们插入自己的值为止。这是否可能,或者这是 mediawiki 上的模板不能做什么?

我的主要问题是:如何包含 mediawiki 模板并让它显示所有内容,包括未定义的变量?例如,如果将新数据添加到模板中,但尚未“填充”,这将非常有用,这将指示需要插入数据。

更新 2011 年 10 月 14 日 @ 下午 3:30 CST:
这是实际的模板(称为 Template:EmployeeInfo):

{{Infobox
  |name         = {{{name}}}
  |title        = {{{title}}}
}}

以及我包含它的方式(页面称为“Employee Drew”):

{{EmployeeInfo
  |name         = Drew
  |title        = My Title
}}

现在...如果我要向模板添加一些内容会怎么样,例如,现在模板看起来像这是:

{{Infobox
  |name         = {{{name}}}
  |title        = {{{title}}}
  |education    = {{{education}}}
}}

即使页面“Employee Drew”(和其他页面)仅定义了名称和标题变量,我如何让包含 Template:EmployeeInfo 的每个页面包含“教育”部分?

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 show 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无远思近则忧 2024-10-29 01:52:33

我认为您的 Template:Infobox 正在测试变量是否为空并且不显示该字段?最简单的方法是在 Template:EmployeeInfo 中为 education 变量指定默认值:

{{Infobox
  |name         = {{{name}}}
  |title        = {{{title}}}
  |education    = {{{education|default value}}}
}}

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}}}
}}
戏蝶舞 2024-10-29 01:52:33

您可以使用 ParserFunctions 扩展 来测试 {{{education}}} 是否变量是否为空,如果是,则用任何内容填充信息框。

{{Infobox
  |name         = {{{name}}}
  |title        = {{{title}}}
  |education    = {{#if: {{{education}}} | {{{education}}} | N/A}}
}}

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}}
}}
挖鼻大婶 2024-10-29 01:52:33

这很旧,但有人可能会发现它很有用。对于未定义的参数,您可以在模板中定义默认值。

例如:{{{name|no name}}}

在这种情况下,如果参数“name”没有定义,模板将输出“no name”。

https://www.mediawiki.org/wiki/Help:Templates#Default_values

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文