跳转到内容

Template:Diff/doc

维基百科,自由的百科全书

模板介紹

[编辑]

此模板用于快速在页面里以外部链接的方式添加指向该页所在语言的维基百科计划的某个指定标题页面版本差异的网页地址。虽然实际效果和直接粘贴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.

參見

[编辑]