模板介绍

编辑

此模板用于快速在页面里以外部链接的方式添加指向该页所在语言的维基百科计划的某个指定标题页面版本差异的网页地址。虽然实际效果和直接粘贴URL地址基本一致,但是使用这个模板可以让长URL看起来更简短一些,也不会有大量的转义符,可以方便以后的编辑修改。

每一个可修改页面在条目上方都有一个历史按钮连接到该页面的页面历史,历史表中可以比较旧版本和当前版本的区别并查看一个特定版本。

使用方法

编辑

{{Diff|title|diff|oldid|label|diffonly=yes}}

{{Diff|{{{1}}}|{{{2}}}|{{{3}}}|{{{4}}}|{{{diffonly}}}}}

参数:

  • {{{1}}}为页面标题(title),通常可选。
  • {{{2}}}为与旧版本比较差异的页面版本或关键词(diff),允许的参数包括:
  • cur — 比较旧版本和当前版本的差异。
  • prev — 比较旧版本和上一版本的差异。
  • next — 比较旧版本和下一版本的差异。
  • id — 与旧版本比较差异的一个更新的版本的ID,比旧版本的ID(oldid)大。
  • {{{3}}}为旧版本的ID(oldid)。
  • {{{4}}}为外部链接上显示的文字(label),可选。
  • |diffonly=yes — 仅显示版本间的差异,可选。如填写,必须完整地写出参数名diffonly,不可以只写yes

所有参数都是可选的,省略的参数必须是空的,但要正常显示差异必须有diff参数(或参数2)和oldid参数(或参数3,title参数并非必须),用法形如{{diff||新版id|旧版id}}或{{diff|diff=新版id|oldid=旧版id}}。您还可以使用命名变数:page=, diff=, oldid=label=

但若只需显示diff参数版本号与之前版本的差异,则oidid参数(或参数3)也可省略,形如{{diff||新版id}}或{{diff|diff=新版id}}。

最后会生成形如以下的外部链接:

[http://{{{语言前缀}}}.wikipedia.org/w/index.php?title={{{1}}}&diff={{{2}}}&oldid={{{3}}} {{{4}}}]

范例

编辑
代码 效果
{{diff|||1111}}

[1]

(相当于 {{oldid|1111}}历史版本1111

{{diff||9999|1111}}

[2]

(对比历史版本9999与非同词条的1111)

{{diff|title|9999|1111}}

[3]

(同上。title 可完全省略)

{{diff||9999}}

[4]

(对比历史版本9999与同词条的前一个历史版本)

{{diff|title|9999}}

[5]

(同上。title 可完全省略)

{{diff||next|1111|label|diffonly=yes}}

label

(对比历史版本1111与同词条的后一个历史版本)

{{diff|title|next|1111|label|diffonly=yes}}

label

(同上。title 可完全省略)

{{diff|title|next}}

[6]

(对比前一个历史版本与当前版本。cur 亦同。prev 则不对比,只显示“无差异”)

{{diff|title}}

[7]

(当前页面)

Code Output
{{diff|Main Page|22778153|22778148|Diff between two numbered versions of a page}} Diff between two numbered versions of a page
  • The page= parameter (parameter number 1) should be a name of a page, for instance Main Page.
  • The diff= parameter (parameter number 2) should be the larger revision number.
  • The oldid= parameter (parameter number 3) should be the smaller revision number.
{{diff|Wikipedia:Pagediff|22778153|22778148|Diff between two numbered versions of a Pagediff page in Wikipedia namespace}} Diff between two numbered versions of a Pagediff page in Wikipedia namespace
  • The page= parameter (parameter number 1) should be a name of a page, for instance Wikipedia:Pagediff.
  • The diff= parameter (parameter number 2) should be the page revision to appear on the right (proposed change).
  • The oldid= parameter (parameter number 3) should be the page revision to appear on the left (original).
{{diff|Main Page|prev|22778153|Diff between a numbered version and the previous version}} Diff between a numbered version and the previous version

This is the form that would be used most often.

  • The diff= parameter (parameter number 2) should be the word prev.
  • The oldid= parameter (parameter number 3) should be the known revision number.
{{diff|Main Page|next|22778153|Diff between a numbered version and the subsequent version}} Diff between a numbered version and the subsequent version
  • The diff= parameter (parameter number 2) should be the word next.
  • The oldid= parameter (parameter number 3) should be the known revision number.
{{diff|Main Page|cur|22778153|Diff between a numbered version and the current version of a page}} Diff between a numbered version and the current version of a page
  • The diff= parameter (parameter number 2) should be the word cur.
  • The oldid= parameter (parameter number 3) should be the known revision number.
{{diff|Main Page|cur||Diff showing the most recent change to a page}} Diff showing the most recent change to a page
  • The diff= parameter (parameter number 2) should be the word cur.
  • The oldid= parameter (parameter number 3) should be empty.
{{diff|Main Page||22778153|A link to a numbered version of a page}} A link to a numbered version of a page
  • The diff= parameter (parameter number 2) should be empty.
  • The oldid= parameter (parameter number 3) should be the known revision number.
  • The result is not actually a diff, so this might be considered misuse of the template. See the {{oldid}} template.

参见

编辑