跳转到内容

模組:Portal/doc

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

这是本页的一个历史版本,由Great Brightstar留言 | 贡献2013年9月16日 (一) 15:21 建立内容为“{{缺乏中文说明}} {{module rating|protected}} This module has two functions, <code>portal</code> and <code>image</code>. The <code>portal</cod...”的新頁面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)

这是Module:Portal的文档页面

This module has two functions, portal and image. The portal produces a box with links to a portal or to multiple portals, and is used by the {{portal}} template. It is most often used in the "See also" section of an article. The image function produces the name of the image used by the specified portal.

Portal function

The portal function produces a box of portal links.

用法

基本

{{#invoke:Portal|portal |Portal 1 |Portal 2 |Portal 3 |... }}

所有参数

{{#invoke:Portal|portal
 | Portal 1
 | Portal 2
 | Portal 3
 | ... 
 | left = <!-- yes -->
 | margin = <!-- CSS margin -->
 | break = <!-- yes -->
 | boxsize = <!-- custom box width in pixels -->
 | image1 = <!-- image override for Portal 1 -->
}}

兼容模式

中文维基百科旧portal模板的参数格式与Lua版本的多参数模式不尽相同。为保证兼容性,Lua模板中也增加了对这两种形式的支持。

name image

如果没有指定位置参数,则尝试将:

{{Portal|name=Portal 1|image=Image 1.png <!-- 可选 -->}}

解读为:

{{Portal|1=Portal 1|image1=Image 1.png <!-- 可选 -->}}

这一步骤并不会让模板运算变得十分复杂,因此基本无需修正到新格式。

2号位作图像

如果参数数量为2,且第二项按照文件名理解时扩展名长度为3或4,则尝试将:

{{Portal|Portal 1|Image 1.xyz}}

解读为:

{{Portal|1=Portal 1|image1=Image 1.xyz}}

为减少误报,模块会在扩展名不是常用图片格式(png、jpg、svg)时检查文件是否存在。检查步骤为“昂贵操作”,对服务器负担较重,因此请检查文档底部的追踪分类进行清理。

位置

在条目里面,本模板通常放置在条目底端的“参见”章节。

举例

Code Result
{{#invoke:Portal|portal|科学}}
{{#invoke:Portal|portal|1=科学|2=弹维基|image2=New-Bouncywikilogo.gif|3=默认图片}}

TemplateData

TemplateData
以下是该模板的模板数据,适用于可视化编辑器等工具。

Portal模板数据

A template to create a list of portals

模板参数

参数描述类型状态
Portal (1)1

Inserts the portal image and text. Further portals can be added to the template by increasing the number

字符串必需
Portal (2)2

Insert the portal image and text

字符串可选
Portal (3)3

Insert the portal image and text

字符串可选
Sideleft

If set to yes, the portal appears on the left side of the page instead of the right.

默认值
no
字符串可选
Margin sizemargin

Alters the margin size. Any valid CSS margin is accepted

数字可选
Line breakbreak

If set to yes, a line break is inserted after the portal name and before the word portal

字符串可选
Box sizeboxsize

This sets a custom box width in pixels.

数字可选

图片

自动配图模块(取代Template:Portal/Images,请检查图像数据是否迁移完毕):

参见

重定向

Image function

The image function produces the name of the image used by the specified portal.

Usage

{{#invoke:Portal|image|portal}}

Example

  • {{#invoke:Portal|image|Art}} → Portal-puzzle.svg

Image dupes function

The image dupes function returns a list of all images that are being used by more than one portal (aliases are not included). This can be helpful in identifying image entries that should be changed to use aliases.

Usage

{{#invoke:Portal|imageDupes}}

Display all function

The display all function returns a box containing all portals that have images. This is used for maintenance, and should not be displayed in articles, because a) there are around 1500 portals with images, and displaying 1500 images on one page takes up a lot of server resources, and b) the module has no way to know the correct capitalisation of a portal name, so some links to portals will be broken.

Usage

{{#invoke:Portal|displayAll}}