【问题标题】:Mediawiki templates and generating standardized pagesMediawiki 模板和生成标准化页面
【发布时间】:2012-07-23 09:34:33
【问题描述】:

我正在使用 mediawiki 管理一些数据,我想知道是否可以从现有的 wiki 数据生成标准化页面,而无需创建大量非常相似的页面。在理想情况下,我会有一个由 CGI 动态填充的数据库后端和页面模板,我想知道是否可以强制 mediawiki 模板系统填充这个角色。

这是我想做的:

数据页

name:      banana
colour:    yellow
tastiness: extremely high
extra:     some more stuff, potentially with complicated wiki formatting
links:     www.banana.com; www.iheartbananas.org
image:     banana.jpg

name:      apple
colour:    red, green
tastiness: variable
extra:     some more stuff 
links:     www.apple-fruit.com

然后为数据库中的每一项,生成一个标准化的页面:

<name> Info

It is generally <colour>
Its tastiness rating is <tastiness>
Read more about <name> at <links>

<image>

mediawiki 模板可以做到这一点吗?

【问题讨论】:

标签: templates mediawiki


【解决方案1】:

模板可以实现,但不一定是好的解决方案。您需要为每个项目创建一个数据模板,如下所示(例如,Template:FruitData/banana):

{{ {{{template}}}
| name =      banana
| colour =    yellow
| tastiness = extremely high
| extra =     some more stuff, potentially with complicated wiki formatting
| link =      www.banana.com
| image =     banana.jpg
}}

和一个显示模板(比如Template:StandardFruitDisplay):

[[File:{{{image}}}|thumb|right]]
The {{{name}}} is a {{{colour}}} fruit with {{{tastiness}}} taste. {{extra|}}} See [http://{{{link}}} {{{{link}}}].

然后在实际页面上显示如下:{{ Template:FruitData/banana | template = StandardFruitDisplay }}

但你可能会更好地使用一些以数据为中心的扩展(除非你的目标是极端的灵活性或用户控制)。

【讨论】:

  • 谢谢,太好了。正如您所说,模板不是最佳解决方案,但这是解决此问题的便捷方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-18
  • 2012-06-07
  • 1970-01-01
  • 2014-10-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多