Template:Fmbox/doc:修订间差异
从求闻适配 Fmbox 文档(模板名与分类对齐中医百科) |
小无编辑摘要 |
||
| (未显示另一用户的1个中间版本) | |||
| 第2行: | 第2行: | ||
{{uses Lua|Module:Message box}} |
{{uses Lua|Module:Message box}} |
||
{{uses TemplateStyles|MediaWiki:Gadget-SiteCommon.css}} |
{{uses TemplateStyles|MediaWiki:Gadget-SiteCommon.css}} |
||
本模板{{tl|fmbox}}為'''頁首與頁尾訊息框'''。 |
本模板{{tl|fmbox}}為'''頁首與頁尾訊息框'''(footer and header message box)。 |
||
本模板可用于构建[[MediaWiki:Sp-contributions-footer-anon]]等系统消息的消息框,也可用于用户页的页首与页脚消息框,以及[[Help:编辑提示|编辑提示]]。 |
|||
本模板与{{tl|ambox}}工作原理类似,大部分参数相同;主要区别在于本框宽度为 100%,且配色风格不同。 |
|||
This template works similarly to {{tl|ambox}} and mostly uses the same parameters. The main differences are that this box is 100% wide and has different colour styles. |
|||
== 使用方法 == |
|||
简易用法如下: |
|||
<pre> |
<pre> |
||
{{fmbox | text = 範例文字。}} |
{{fmbox | text = 範例文字。}} |
||
| 第15行: | 第15行: | ||
{{fmbox | text = 範例文字。}} |
{{fmbox | text = 範例文字。}} |
||
完整 |
完整用法如下: |
||
<pre> |
<pre> |
||
{{fmbox |
{{fmbox |
||
| 第34行: | 第34行: | ||
}} |
}} |
||
== 页首与页尾消息框类型 == |
|||
=== Footer and header message box types === |
|||
以下示例使用了不同的<code>type</code>参数,但未指定<code>image</code>参数,因此会显示各类型的默认图片。 |
|||
The following examples use different '''type''' parameters but use no image parameters thus they use the default images for each type. |
|||
{{fmbox |
{{fmbox |
||
| type = warning |
| type = warning |
||
| text = type=<u>warning</u> |
| text = type=<u>warning</u> —— 警告通知,如 [[MediaWiki:Revision-info]] 与 [[MediaWiki:Protectedpagewarning]]。 |
||
}} |
}} |
||
{{fmbox |
{{fmbox |
||
| type = editnotice |
| type = editnotice |
||
| text = type=<u>editnotice</u> |
| text = type=<u>editnotice</u> —— 透明背景,用于[[Help:编辑提示|编辑提示]]。 |
||
}} |
}} |
||
{{fmbox |
{{fmbox |
||
| type = system |
| type = system |
||
| text = type=<u>system</u> |
| text = type=<u>system</u> —— 浅灰色系统消息背景(默认)。 |
||
}} |
}} |
||
== 其他图片 == |
|||
上方显示的默认图片大多用于测试与演示。多数情况下,更适合使用更具体的图片,或完全不使用图片。以下示例通过<code>image</code>参数指定了默认图片以外的图片。 |
|||
The default images shown above are mostly for testing and demonstration. In most cases it is more appropriate to use a more specific image or no image at all. These examples use the '''image''' parameter to specify an image other than the default image. |
|||
{{fmbox |
{{fmbox |
||
| image = [[File:User-info.svg|40px]] |
| image = [[File:User-info.svg|40px]] |
||
| text = image = <nowiki>[[File:User-info.svg|40px]]</nowiki> <br> |
| text = image = <nowiki>[[File:User-info.svg|40px]]</nowiki> <br> 此图片用于 [[MediaWiki:Sp-contributions-footer]]。 |
||
}} |
}} |
||
=== Special === |
|||
== 特殊用法 == |
|||
Some other parameter combinations. |
|||
一些其他参数组合。 |
|||
{{fmbox |
{{fmbox |
||
| text = |
| text = 未指定图片(默认) |
||
}} |
}} |
||
{{fmbox |
{{fmbox |
||
| image = none |
| image = none |
||
| text = '''image=none''' |
| text = '''image=none''' —— 不使用图片,<code>text</code>占满整个消息框区域。 |
||
}} |
}} |
||
{{fmbox |
{{fmbox |
||
| 第77行: | 第79行: | ||
}} |
}} |
||
== 参数 == |
|||
全部参数列表: |
|||
List of all parameters: |
|||
<pre> |
<pre> |
||
| 第90行: | 第92行: | ||
| style = CSS values |
| style = CSS values |
||
| textstyle = CSS values |
| textstyle = CSS values |
||
| text = |
| text = 消息正文。 |
||
}} |
}} |
||
</pre> |
</pre> |
||
'''type''' |
'''type''' |
||
:若未指定<code>type</code>参数,模板默认使用 type=<u>system</u>,即浅灰色背景。 |
|||
:If no '''type''' parameter is given the template defaults to type '''system'''. That means it gets a light grey background. |
|||
'''image''' |
'''image''' |
||
:'''未指定参数''' = 未指定<code>image</code>参数时,模板会根据<code>type</code>参数使用对应的默认图片。 |
|||
:'''No parameter''' = If no '''image''' parameter is given the template uses a default image. Which default image it uses depends on the '''type''' parameter. |
|||
:'''指定图片''' = 应使用常规 wiki 图片语法,例如: |
|||
:'''An image''' = Should be an image with usual wiki notation. 40px - 50px width are usually about right depending on the image height to width ratio. (But the message box can handle images of any size.) For example: |
|||
::<code><nowiki>image = [[File:User-info.svg|40px]]</nowiki></code> |
::<code><nowiki>image = [[File:User-info.svg|40px]]</nowiki></code> |
||
::宽度 40px–50px 通常比较合适(取决于图片宽高比);消息框可容纳任意尺寸的图片。 |
|||
:'''none''' = Means that no image is used. |
|||
:'''none''' = 不使用图片。 |
|||
'''imageright''' |
'''imageright''' |
||
:'''未指定参数''' = 未指定<code>imageright</code>参数时,右侧不显示图片。 |
|||
:'''No parameter''' = If no '''imageright''' parameter is given then no image is shown on the right side. |
|||
:'''指定图片''' = 应使用常规 wiki 图片语法,例如: |
|||
:'''An image''' = Should be an image with usual wiki notation. 40px - 50px width are usually about right depending on the image height to width ratio. (But the message box can handle images of any size.) For example: |
|||
::<code><nowiki>imageright = [[File:Nuvola apps bookcase.png|40px]]</nowiki></code> |
::<code><nowiki>imageright = [[File:Nuvola apps bookcase.png|40px]]</nowiki></code> |
||
::宽度 40px–50px 通常比较合适;消息框可容纳任意尺寸的图片。 |
|||
:'''Anything''' = Any other object that you want to show on the right side. |
|||
:'''任意内容''' = 可在右侧显示任意其他对象。 |
|||
'''id''' |
'''id''' |
||
:整个消息框的可选CSS id,不带引号 <code>" "</code>。主要用于标记消息框名称,便于 JavaScript 检测。例如 [[MediaWiki:Sp-contributions-footer]] 使用: |
|||
:Optional [[层叠样式表|CSS]] id used by the entire message box table. Without quotation marks <code>" "</code>. Mostly meant to be used to tag a message box with its name, to make it easy to detect the presence of the message from javascript. For instance [[MediaWiki:Sp-contributions-footer]] would use: |
|||
::<code>id = sp-contributions-footer</code> |
::<code>id = sp-contributions-footer</code> |
||
'''class''' |
'''class''' |
||
: |
:整个消息框的可选CSS类名,不带引号 <code>" "</code>。主要用于标记消息框名称,便于单独定制皮肤。例如 [[MediaWiki:Sp-contributions-footer]] 使用: |
||
::<code>class = sp-contributions-footer</code> |
::<code>class = sp-contributions-footer</code> |
||
'''style''' |
'''style''' |
||
: |
:整个消息框的可选CSS样式,不带引号 <code>" "</code>,但需以分号 <code>;</code> 结尾。例如: |
||
::<code>style = margin-top: 1em;</code> |
::<code>style = margin-top: 1em;</code> |
||
'''textstyle''' |
'''textstyle''' |
||
:文字单元格的可选CSS样式。例如: |
|||
:Optional [[层叠样式表|CSS]] values used by the text cell. For example: |
|||
::<code>textstyle = font-size: 90%; text-align: center;</code> |
::<code>textstyle = font-size: 90%; text-align: center;</code> |
||
'''text''' |
'''text''' |
||
:消息正文。 |
|||
:The message body text. |
|||
== 技术细节 == |
|||
本模板目前使用硬编码的样式与类名,未来将仅使用 CSS 类以便更换皮肤(目前可通过 "<code>!important</code>" 关键字覆盖样式)。 |
|||
This template currently uses hard coded styles and class names. Later it will only use CSS classes making it easier to skin. (In the meantime it can be skinned by using the "<code>!important</code>" keyword.) |
|||
如需制作宽度小于 100% 的消息框,请''不要''使用本模板,改用{{tl|ombox}}。因为本框没有使其他消息框在宽度小于 100% 时于所有浏览器中获得正确框流布局的"1px 空图片单元格"代码。 |
|||
If you need to make a box that is less than 100% wide, then do ''not'' use this box, instead use the {{tl|ombox}}. Since this box doesn't have the "1px empty image cell" code that makes it so the other mboxes get proper box flow in all browsers when less than 100% wide. |
|||
若需在<code>text</code>参数中使用特殊字符,需如下转义: |
|||
If you need to use special characters in the text parameter then you need to escape them like this: |
|||
<pre> |
<pre> |
||
{{fmbox |
{{fmbox |
||
| text = <div> |
| text = <div> |
||
等号 = 与前后大括号 { } 可以正常使用。 |
|||
Equal sign = and a start and end brace { } work fine as they are. |
|||
但管道符 {{!}} 与两个相连的后大括号 <nowiki>}}</nowiki> 不能直接使用。 |
|||
一起使用同样需要 nowiki 标记 <nowiki>|}}</nowiki>。 |
|||
</div> |
</div> |
||
}} |
}} |
||
| 第148行: | 第152行: | ||
{{fmbox |
{{fmbox |
||
| text = <div> |
| text = <div> |
||
等号 = 与前后大括号 { } 可以正常使用。 |
|||
Equal sign = and a start and end brace { } work fine as they are. |
|||
但管道符 {{!}} 与两个相连的后大括号 <nowiki>}}</nowiki> 不能直接使用。 |
|||
一起使用同样需要 nowiki 标记 <nowiki>|}}</nowiki>。 |
|||
</div> |
</div> |
||
}} |
}} |
||
本元模板内部使用 HTML 标记而非维基表格标记。这是制作元模板的常见做法,因为维基表格标记存在若干缺陷,例如难以在参数中使用解析器函数和特殊字符。 |
|||
Internally this meta-template uses HTML wikimarkup instead of wikimarkup for the table code. That is the usual way we make meta-templates since wikimarkup has several drawbacks. For instance it makes it harder to use parser functions and some special characters in parameters. |
|||
'''管理员注意:'''MediaWiki 不会像处理普通页面那样解析和转换系统消息中的 HTML 标记。例如 <code><br></code> 不会自动转换为 <code><br /></code>,缺失的 <code></td></code> 与 <code></tr></code> 标签不会自动补全。因此请确保系统消息中的 HTML 代码为有效的 XHTML,即闭合所有开启的标签。不过,常规维基标记在多数系统消息中可正常工作。 |
|||
'''Note to admins:''' MediaWiki does not parse and convert HTML wikimarkup in system messages the same way as it does for normal pages. This means for instance that <code><br></code> is not automatically converted to <code><br /></code> and missing <code></td></code> and <code></tr></code> tags are not automatically added. Thus see to that any HTML code you use in system messages are valid XHTML. That is, close all tags that you begin. However, regular wikimarkup works fine in most system messages. |
|||
更多技术细节参见[[Template talk:Fmbox|讨论页]]。由于本模板与{{tl|mbox}}、{{tl|ambox}}、{{tl|tmbox}}和{{tl|ombox}}的工作方式几乎完全相同,它们的讨论页及相关页面也可能包含更多细节。 |
|||
For more technical details see the [[Template talk:Fmbox|talk page]]. Since this template works almost exactly like {{tl|ambox}}, {{tl|tmbox}}, {{tl|imbox}}, {{tl|cmbox}} and {{tl|ombox}} their talk pages and related pages might also contain more details. |
|||
== 参见 == |
|||
{{Mbox templates see also}} |
{{Mbox templates see also}} |
||
2026年8月7日 (五) 11:11的最新版本
本模板{{fmbox}}为页首与页尾讯息框(footer and header message box)。
本模板可用于构建MediaWiki:Sp-contributions-footer-anon等系统消息的消息框,也可用于用户页的页首与页脚消息框,以及编辑提示。
本模板与{{ambox}}工作原理类似,大部分参数相同;主要区别在于本框宽度为 100%,且配色风格不同。
使用方法
简易用法如下:
{{fmbox | text = 範例文字。}}
完整用法如下:
{{fmbox
| type = editnotice
| image = [[File:Emblem-question-yellow.svg|40px]]
| style = border: 1px solid #f4c430;
| textstyle = color: red; font-weight: bold; font-style: italic;
| text = 訊息主體文字。
}}
页首与页尾消息框类型
以下示例使用了不同的type参数,但未指定image参数,因此会显示各类型的默认图片。
其他图片
上方显示的默认图片大多用于测试与演示。多数情况下,更适合使用更具体的图片,或完全不使用图片。以下示例通过image参数指定了默认图片以外的图片。
此图片用于 MediaWiki:Sp-contributions-footer。
特殊用法
一些其他参数组合。
text占满整个消息框区域。参数
全部参数列表:
{{fmbox
| type = system / editnotice / warning
| image = none / [[File:Some image.svg|40px]]
| imageright = [[File:Some image.svg|40px]]
| id = CSS id
| class = CSS class names
| style = CSS values
| textstyle = CSS values
| text = 消息正文。
}}
type
- 若未指定
type参数,模板默认使用 type=system,即浅灰色背景。
image
- 未指定参数 = 未指定
image参数时,模板会根据type参数使用对应的默认图片。 - 指定图片 = 应使用常规 wiki 图片语法,例如:
image = [[File:User-info.svg|40px]]- 宽度 40px–50px 通常比较合适(取决于图片宽高比);消息框可容纳任意尺寸的图片。
- none = 不使用图片。
imageright
- 未指定参数 = 未指定
imageright参数时,右侧不显示图片。 - 指定图片 = 应使用常规 wiki 图片语法,例如:
imageright = [[File:Nuvola apps bookcase.png|40px]]- 宽度 40px–50px 通常比较合适;消息框可容纳任意尺寸的图片。
- 任意内容 = 可在右侧显示任意其他对象。
id
- 整个消息框的可选CSS id,不带引号
" "。主要用于标记消息框名称,便于 JavaScript 检测。例如 MediaWiki:Sp-contributions-footer 使用:id = sp-contributions-footer
class
- 整个消息框的可选CSS类名,不带引号
" "。主要用于标记消息框名称,便于单独定制皮肤。例如 MediaWiki:Sp-contributions-footer 使用:class = sp-contributions-footer
style
- 整个消息框的可选CSS样式,不带引号
" ",但需以分号;结尾。例如:style = margin-top: 1em;
textstyle
- 文字单元格的可选CSS样式。例如:
textstyle = font-size: 90%; text-align: center;
text
- 消息正文。
技术细节
本模板目前使用硬编码的样式与类名,未来将仅使用 CSS 类以便更换皮肤(目前可通过 "!important" 关键字覆盖样式)。
如需制作宽度小于 100% 的消息框,请不要使用本模板,改用{{ombox}}。因为本框没有使其他消息框在宽度小于 100% 时于所有浏览器中获得正确框流布局的"1px 空图片单元格"代码。
若需在text参数中使用特殊字符,需如下转义:
{{fmbox
| text = <div>
等号 = 与前后大括号 { } 可以正常使用。
但管道符 {{!}} 与两个相连的后大括号 }} 不能直接使用。
一起使用同样需要 nowiki 标记 |}}。
</div>
}}
等号 = 与前后大括号 { } 可以正常使用。 但管道符 | 与两个相连的后大括号 }} 不能直接使用。 一起使用同样需要 nowiki 标记 |}}。
本元模板内部使用 HTML 标记而非维基表格标记。这是制作元模板的常见做法,因为维基表格标记存在若干缺陷,例如难以在参数中使用解析器函数和特殊字符。
管理员注意:MediaWiki 不会像处理普通页面那样解析和转换系统消息中的 HTML 标记。例如 不会自动转换为 ,缺失的 与 标签不会自动补全。因此请确保系统消息中的 HTML 代码为有效的 XHTML,即闭合所有开启的标签。不过,常规维基标记在多数系统消息中可正常工作。
更多技术细节参见讨论页。由于本模板与{{mbox}}、{{ambox}}、{{tmbox}}和{{ombox}}的工作方式几乎完全相同,它们的讨论页及相关页面也可能包含更多细节。
参见
- {{mbox}} – 多命名空间消息框(自动检测命名空间)
- {{ambox}} – 条目消息框
- {{tmbox}} – 讨论页消息框
- {{ombox}} – 其他页面消息框
- {{fmbox}} – 页眉和页脚消息框
- {{dmbox}} – 消歧义消息框