个人工具

Wikipedia:变量

来自Ubuntu中文

跳转至: 导航, 搜索

wiki中的文章中可以使用变量,以便于显示时间、条目数等动态数据。这些变量也经常在模板中使用。

下面的列表中,左侧是变量的书写方式,右侧是在本站中的表现结果。

时间变量

变量 结果 说明
{{CURRENTTIME}} 01:40 当前UTC时间
{{CURRENTDAY}} 19 当前日期
{{CURRENTMONTH}} 04 当前月份
{{CURRENTYEAR}} 2024 当前年份
{{CURRENTDAYNAME}} 星期五 当前为星期几的中文字串
{{CURRENTMONTHNAME}} 4月 当前月份的中文字串
{{CURRENTMONTHNAMEGEN}} 四月 当前月份的中文字串2
{{NUMBEROFARTICLES}} 2,239 本站现有正式文章数【注1】

【注1】:NUMBEROFARTICLES变量只计算主名字空间中至少包含一个链接的条目,但不包括重定向条目。由前可知,分类帮助重定向等条目以及讨论页面并不被计算在内。

依赖于页面的变量

{{NAMESPACE}}
{{PAGENAME}} Wikipedia:变量
{{PAGENAMEE}} Wikipedia:%E5%8F%98%E9%87%8F

上面的变量在template名字空间中使用时, 他们将作用于所提交的页面,而不是模板页面。

例子

{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|action=edit}} https://wiki.ubuntu.org.cn/index.php?title=Wikipedia:%E5%8F%98%E9%87%8F&action=edit
[[{{NAMESPACE}}:{{PAGENAME}}_1]] Wikipedia:变量_1
{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}_1}} https://wiki.ubuntu.org.cn/Wikipedia:%E5%8F%98%E9%87%8F_1

In a template, for a link to a page which depends on a template parameter, the external link style is used even for internal links, to avoid that the system links to the edit page even if the page exists. To construct the external link, variables can also be useful.


常量,显示各种项目名称

{{ns:-2}} 或 {{ns:Media}} 媒体文件
{{ns:-1}} 或 {{ns:Special}} 特殊
{{ns:1}} 或 {{ns:Talk}} 讨论
{{ns:2}} 或 {{ns:User}} 用户
{{ns:3}} 或 {{ns:User_talk}} 用户讨论
{{ns:4}} 或 {{ns:Project}} Ubuntu中文
{{ns:5}} 或 {{ns:Project_talk}} Ubuntu中文讨论
{{ns:6}} 或 {{ns:Image}} 文件
{{ns:7}} 或 {{ns:Image_talk}} 文件讨论
{{ns:8}} 或 {{ns:MediaWiki}} MediaWiki
{{ns:9}} 或 {{ns:MediaWiki_talk}} MediaWiki讨论
{{ns:10}} 或 {{ns:Template}} 模板
{{ns:11}} 或 {{ns:Template_talk}} 模板讨论
{{ns:12}} 或 {{ns:Help}} 帮助
{{ns:13}} 或 {{ns:Help_talk}} 帮助讨论
{{ns:14}} 或 {{ns:Category}} 分类
{{ns:15}} 或 {{ns:Category_talk}} 分类讨论
{{SITENAME}} Ubuntu中文
{{SERVER}} https://wiki.ubuntu.org.cn
{{localurl:页面名称}} /%E9%A1%B5%E9%9D%A2%E5%90%8D%E7%A7%B0
{{localurl:页面名称|查询字符串}} /index.php?title=%E9%A1%B5%E9%9D%A2%E5%90%8D%E7%A7%B0&查询字符串