Template:Cmbox/doc: Difference between revisions
en>Tholme No edit summary |
m 1 revision imported: box update |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{Mbox templates}} | |||
{{Documentation subpage}} | {{Documentation subpage}} | ||
<!-- | <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> | ||
{{ | {{Lua|Module:Message box{{\sandbox}}}} | ||
{{Uses TemplateStyles|Module:Message box/ambox.css}} | |||
{{ | |||
This is the {{tl|Cmbox}} (['''C''']ategory ['''m''']essage ['''box''']) | This is the {{tl|Cmbox}} (['''C''']ategory ['''m''']essage ['''box''']) metatemplate. | ||
It is used to build message box templates | It is used to build message box templates for category pages. It offers several different colours, uses default images if no image parameter is given, and it has some other features. | ||
This template works almost exactly like {{tl|Ambox}} and uses the same parameters. | This template works almost exactly like {{tl|Ambox}} and uses the same parameters. | ||
| Line 14: | Line 13: | ||
=== Usage === | === Usage === | ||
Simple usage example: | Simple usage example: | ||
< | <pre> | ||
{{cmbox | text = Some text.}} | {{cmbox | text = Some text.}} | ||
</ | </pre> | ||
{{cmbox | text = Some text.}} | {{cmbox{{\sandbox}} | text = Some text.}} | ||
Complex example: | Complex example: | ||
< | <pre> | ||
{{cmbox | {{cmbox | ||
| type = style | | type = style | ||
| Line 30: | Line 29: | ||
| text = The message body text. | | text = The message body text. | ||
}} | }} | ||
</ | </pre> | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = style | | type = style | ||
| image = [[File:Emblem-question-yellow.svg|40px]] | | image = [[File:Emblem-question-yellow.svg|40px]] | ||
| Line 44: | Line 43: | ||
The following examples use different '''type''' parameters but use no image parameters, thus they use the default images for each type. | The following examples use different '''type''' parameters but use no image parameters, thus they use the default images for each type. | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = speedy | | type = speedy | ||
| text = type=<u>speedy</u> – Speedy deletion templates such as {{tl|db-c1}}. | | text = type=<u>speedy</u> – Speedy deletion templates such as {{tl|db-c1}}. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = delete | | type = delete | ||
| text = type=<u>delete</u> – Deletion templates such as {{tl|cfd}}. | | text = type=<u>delete</u> – Deletion templates such as {{tl|cfd}}. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = content | | type = content | ||
| text = type=<u>content</u> – Major warnings and problems such as {{tl|Categorization of people disputed}}. | | text = type=<u>content</u> – Major warnings and problems such as {{tl|Categorization of people disputed}}. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = style | | type = style | ||
| text = type=<u>style</u> – Minor warnings and problems such as {{tl| | | text = type=<u>style</u> – Minor warnings and problems such as {{tl|Underpopulated category}}. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = notice | | type = notice | ||
| text = type=<u>notice</u> – Notices and messages of any kind, both permanent and temporary. | | text = type=<u>notice</u> – Notices and messages of any kind, both permanent and temporary. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = move | | type = move | ||
| text = type=<u>move</u> – Move, merge, and split messages and proposals such as {{tl|Category redirect}}. | | text = type=<u>move</u> – Move, merge, and split messages and proposals such as {{tl|Category redirect}}. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = protection | | type = protection | ||
| text = type=<u>protection</u> – Protection templates such as {{tl|pp}} when shown on a category page. | | text = type=<u>protection</u> – Protection templates such as {{tl|pp}} when shown on a category page. | ||
| Line 82: | Line 81: | ||
The default images shown above are mostly for convenience. In many cases it is more appropriate to use more specific images. These examples use the '''image''' parameter to specify an image other than the default images. | The default images shown above are mostly for convenience. In many cases it is more appropriate to use more specific images. These examples use the '''image''' parameter to specify an image other than the default images. | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = style | | type = style | ||
| image = [[File:Sub-arrows.svg|40px]] | | image = [[File:Sub-arrows.svg|40px]] | ||
| text = type = style<br />image = <nowiki>[[File:Sub-arrows.svg|40px]]</nowiki><br />This image is used for {{tl| | | text = type = style<br />image = <nowiki>[[File:Sub-arrows.svg|40px]]</nowiki><br />This image is used for {{tl|Very large}} and {{tl|Category diffuse}}. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| type = move | | type = move | ||
| image = [[File:Redirect arrow.svg | | image = [[File:Redirect arrow.svg|52px]] | ||
| text = type = move<br />image = <nowiki>[[File:Redirect arrow.svg | | text = type = move<br />image = <nowiki>[[File:Redirect arrow.svg|52px]]</nowiki><br />This image is used for {{tl|Category redirect}}. | ||
}} | }} | ||
| Line 98: | Line 97: | ||
Some other parameter combinations. | Some other parameter combinations. | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| text = No type and no image given ('''default''') | | text = No type and no image given ('''default''') | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| image = none | | image = none | ||
| text = No type and '''image=none''' – No image is used and the '''text''' uses the whole message box area. | | text = No type and '''image=none''' – No image is used and the '''text''' uses the whole message box area. | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| image = [[File:Gnome globe current event.svg|42px]] | | image = [[File:Gnome globe current event.svg|42px]] | ||
| imageright = [[File:Nuvola apps bookcase.svg|40px]] | | imageright = [[File:Nuvola apps bookcase.svg|40px]] | ||
| Line 113: | Line 112: | ||
}} | }} | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| image = [[File:Gnome globe current event.svg|42px]] | | image = [[File:Gnome globe current event.svg|42px]] | ||
| imageright = [[File:Shuttle.svg|20px]] | | imageright = [[File:Shuttle.svg|20px]] | ||
| text = '''This category lists articles about current and recent [[ | | text = '''This category lists articles about current and recent [[w:Spaceflight|spaceflights]].'''<br />It is populated by the {{tl|Current spaceflight}} template. | ||
}} | }} | ||
| Line 122: | Line 121: | ||
=== Parameters === | === Parameters === | ||
List of all parameters: | List of all parameters: | ||
< | <pre> | ||
{{cmbox | {{cmbox | ||
| type = speedy / delete / content / style / notice / move / protection | | type = speedy / delete / content / style / notice / move / protection | ||
| image = none / [[File:Some image.svg|40px]] | | image = none / [[File:Some image.svg|40px]] | ||
| Line 134: | Line 132: | ||
| text = The message body text. | | text = The message body text. | ||
}} | }} | ||
</ | </pre> | ||
'''type''' | '''type''' | ||
| Line 151: | Line 146: | ||
:'''No parameter''' = If no '''imageright''' parameter is given, no image is shown on the right side. | :'''No parameter''' = If no '''imageright''' parameter is given, no image is shown on the right side. | ||
:'''An image''' = Should be an image with usual wiki notation. 40px - 50px width is usually about right depending on the image height-to-width ratio (but the message box can handle images of any size). | :'''An image''' = Should be an image with usual wiki notation. 40px - 50px width is 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. | ::For example: <code><nowiki>imageright = [[File:Nuvola apps bookcase.svg|40px]]</nowiki></code> | ||
:'''Anything''' = Any other object that you want to show on the right side. | :'''Anything''' = Any other object that you want to show on the right side. | ||
'''style''' | '''style''' | ||
:An optional [[Cascading Style Sheets|CSS]] value used by the entire message box table. Without quotation marks <code>" "</code>. | :An optional [[w:Cascading Style Sheets|CSS]] value used by the entire message box table. Without quotation marks <code>" "</code>. | ||
::For example: <code>style = margin-bottom: 0.5em;</code> | ::For example: <code>style = margin-bottom: 0.5em;</code> | ||
'''textstyle''' | '''textstyle''' | ||
:An optional [[Cascading Style Sheets|CSS]] value used by the text cell. | :An optional [[w:Cascading Style Sheets|CSS]] value used by the text cell. | ||
::For example: <code>textstyle = text-align: center;</code> | ::For example: <code>textstyle = text-align: center;</code> | ||
| Line 170: | Line 165: | ||
=== Technical details === | === Technical details === | ||
If you need to use special characters in the text parameter then you need to escape them like this: | If you need to use special characters in the text parameter then you need to escape them like this: | ||
< | <pre> | ||
{{cmbox | {{cmbox | ||
| text = <div> | | text = <div> | ||
Equal sign = and a start and end brace { } work fine as they are. | Equal sign = and a start and end brace { } work fine as they are. | ||
But here is a pipe {{!}} and two end braces | But here is a pipe {{!}} and two end braces <nowiki>}}</nowiki>. | ||
And now a pipe and end braces | And now a pipe and end braces <nowiki>|}}</nowiki>. | ||
</div> | </div> | ||
}} | }} | ||
</ | </pre> | ||
{{cmbox | {{cmbox{{\sandbox}} | ||
| text = <div> | | text = <div> | ||
Equal sign = and a start and end brace { } work fine as they are. | Equal sign = and a start and end brace { } work fine as they are. | ||
| Line 189: | Line 184: | ||
This template uses the cmbox CSS classes in | This template uses the cmbox CSS classes in {{Blue|MediaWiki:Common.css}} for most of its looks, thus it is fully skinnable. | ||
Internally this meta-template uses HTML markup instead of wiki markup for the table code. That is the usual way we make meta-templates since wiki markup has several drawbacks. For instance it makes it harder to use [[ | Internally this meta-template uses HTML markup instead of wiki markup for the table code. That is the usual way we make meta-templates since wiki markup has several drawbacks. For instance it makes it harder to use [[Help:Extension:ParserFunctions|parser functions]] and special characters in parameters. | ||
The default images for this meta-template are in PNG format instead of SVG format. The main reason is that some older web browsers have trouble with the transparent background that MediaWiki renders for SVG images. The PNG images here have hand-optimised transparent background colour so they look good in all browsers. Note that SVG icons only look somewhat bad in the old browsers, thus such hand optimisation is only worth the trouble for very widely used icons. | The default images for this meta-template are in PNG format instead of SVG format. The main reason is that some older web browsers have trouble with the transparent background that MediaWiki renders for SVG images. The PNG images here have hand-optimised transparent background colour so they look good in all browsers. Note that SVG icons only look somewhat bad in the old browsers, thus such hand optimisation is only worth the trouble for very widely used icons. | ||
| Line 197: | Line 192: | ||
For more technical details see the [[Template talk:Cmbox|talk page]]. Since this template works almost exactly like the other mboxes, their talk pages and related pages might also contain more details (see the [[#See also|See also]] section below). | For more technical details see the [[Template talk:Cmbox|talk page]]. Since this template works almost exactly like the other mboxes, their talk pages and related pages might also contain more details (see the [[#See also|See also]] section below). | ||
== | == TemplateData == | ||
{{Mbox | {{Mbox/TemplateData}} | ||
<includeonly>{{Sandbox other|| | <includeonly>{{Sandbox other|| | ||
<!-- Categories | <!-- Categories below this line; interwikis at Wikidata --> | ||
[[Category:Mbox | [[Category:Mbox templates{{#translation:}}]] | ||
}}</includeonly> | }}</includeonly> | ||
Latest revision as of 17:21, 13 March 2026
| File:Codex icon book color-base.svg | This is a documentation subpage for Template:Cmbox. It contains usage information, categories and other content that is not part of the original Template page. |
[[Category:Template documentation pages{{#translation:}}]]
| This template uses Lua: |
This is the {{Cmbox}} ([C]ategory [m]essage [box]) metatemplate.
It is used to build message box templates for category pages. It offers several different colours, uses default images if no image parameter is given, and it has some other features.
This template works almost exactly like {{Ambox}} and uses the same parameters.
Usage
Simple usage example:
{{cmbox | text = Some text.}}
| File:Information icon4.svg | Some text. |
Complex example:
{{cmbox
| type = style
| image = [[File:Emblem-question-yellow.svg|40px]]
| style = width: 400px;
| textstyle = color: red; font-weight: bold; font-style: italic;
| text = The message body text.
}}
| File:Emblem-question-yellow.svg | The message body text. |
Category message box types
The following examples use different type parameters but use no image parameters, thus they use the default images for each type.
| File:Ambox warning pn.svg | type=speedy – Speedy deletion templates such as {{db-c1}}. |
| File:Ambox warning pn.svg | type=delete – Deletion templates such as {{cfd}}. |
| File:Ambox important.svg | type=content – Major warnings and problems such as {{Categorization of people disputed}}. |
| File:Edit-clear.svg | type=style – Minor warnings and problems such as {{Underpopulated category}}. |
| File:Information icon4.svg | type=notice – Notices and messages of any kind, both permanent and temporary. |
| File:Merge-split-transwiki default.svg | type=move – Move, merge, and split messages and proposals such as {{Category redirect}}. |
| File:Semi-protection-shackle-keyhole.svg | type=protection – Protection templates such as {{pp}} when shown on a category page. |
Other images
The default images shown above are mostly for convenience. In many cases it is more appropriate to use more specific images. These examples use the image parameter to specify an image other than the default images.
| File:Sub-arrows.svg | type = style image = [[File:Sub-arrows.svg|40px]] This image is used for {{Very large}} and {{Category diffuse}}. |
| File:Redirect arrow.svg | type = move image = [[File:Redirect arrow.svg|52px]] This image is used for {{Category redirect}}. |
Special
Some other parameter combinations.
| File:Information icon4.svg | No type and no image given (default) |
| No type and image=none – No image is used and the text uses the whole message box area. |
| File:Gnome globe current event.svg | image = [[File:Gnome globe current event.svg|42px]] imageright = [[File:Nuvola apps bookcase.svg|40px]] | File:Nuvola apps bookcase.svg |
| File:Gnome globe current event.svg | This category lists articles about current and recent spaceflights. It is populated by the {{Current spaceflight}} template. | File:Shuttle.svg |
Parameters
List of all parameters:
{{cmbox
| type = speedy / delete / content / style / notice / move / protection
| image = none / [[File:Some image.svg|40px]]
| imageright = [[File:Some image.svg|40px]]
| class = A custom CSS class to apply to the box
| style = CSS values
| textstyle = CSS values
| plainlinks = no
| text = The message body text.
}}
type
- If no type parameter is given, the template defaults to type notice. That means it gets a blue background.
image
- No parameter = If no image parameter is given, the template uses a default image. Which default image it uses depends on the type parameter.
- An image = Should be an image with usual wiki notation. 40px - 50px width is usually about right depending on the image height-to-width ratio (but the message box can handle images of any size).
- For example:
image = [[File:Sub-arrows.svg|40px]]
- For example:
- none = Means that no image is used.
imageright
- No parameter = If no imageright parameter is given, no image is shown on the right side.
- An image = Should be an image with usual wiki notation. 40px - 50px width is usually about right depending on the image height-to-width ratio (but the message box can handle images of any size).
- For example:
imageright = [[File:Nuvola apps bookcase.svg|40px]]
- For example:
- Anything = Any other object that you want to show on the right side.
style
- An optional CSS value used by the entire message box table. Without quotation marks
" ".- For example:
style = margin-bottom: 0.5em;
- For example:
textstyle
- An optional CSS value used by the text cell.
- For example:
textstyle = text-align: center;
- For example:
plainlinks
- Normally on Wikipedia, external links have an arrow icon next to them, like this: Example.com. However, in message boxes, the arrow icon is suppressed by default, like this: Example.com. To get the normal style of external link with the arrow icon, use
|plainlinks=no.
text
- The message body text.
Technical details
If you need to use special characters in the text parameter then you need to escape them like this:
{{cmbox
| text = <div>
Equal sign = and a start and end brace { } work fine as they are.
But here is a pipe {{!}} and two end braces <nowiki>}}</nowiki>.
And now a pipe and end braces <nowiki>|}}</nowiki>.
</div>
}}
| File:Information icon4.svg | Equal sign = and a start and end brace { } work fine as they are. But here is a pipe | and two end braces }}. And now a pipe and end braces |}}. |
This template uses the cmbox CSS classes in MediaWiki:Common.css for most of its looks, thus it is fully skinnable.
Internally this meta-template uses HTML markup instead of wiki markup for the table code. That is the usual way we make meta-templates since wiki markup has several drawbacks. For instance it makes it harder to use parser functions and special characters in parameters.
The default images for this meta-template are in PNG format instead of SVG format. The main reason is that some older web browsers have trouble with the transparent background that MediaWiki renders for SVG images. The PNG images here have hand-optimised transparent background colour so they look good in all browsers. Note that SVG icons only look somewhat bad in the old browsers, thus such hand optimisation is only worth the trouble for very widely used icons.
For more technical details see the talk page. Since this template works almost exactly like the other mboxes, their talk pages and related pages might also contain more details (see the See also section below).
TemplateData
Template:TemplateData header <templatedata> { "description": {
"cs": "Toto je specializovaná verze metašablony
| File:Information icon4.svg |
nebo “multi namespace message box“.", "en": "This is the specialized version of the
| File:Information icon4.svg |
or \"multi-namespace message box\" meta-template.", "pt-br": "Esta é a versão especializada da meta-predefinição
| File:Information icon4.svg |
, ou “caixa de mensagem para múltiplos espaços nominais”."
},
"format": "block",
"params": {
"type": {
"label": {
"en": "Type",
"cs": "Typ",
"pt-br": "Tipo"
},
"suggestedvalues": [
"notice",
"style",
"content",
"delete",
"speedy",
"protection",
"move"
],
"type": "string",
"default": "notice",
"suggested": true,
"description": "Adjusts border and background for the appropriate use-case. Default notice is gray with a blue border.",
"autovalue": "notice"
},
"image": {
"label": {
"en": "Image (left)",
"cs": "Obrázek (vlevo)",
"pt-br": "Imagem (esquerda)"
},
"suggestedvalues": [
"none"
],
"default": {
"en": "Depends on the “type” parameter.",
"cs": "Závisí na parametru “type“.",
"pt-br": "Depende do parâmetro “type”."
},
"suggested": true,
"type": "content"
},
"imageright": {
"label": {
"en": "Image (right)",
"cs": "Obrázek (vpravo)",
"pt-br": "Imagem (direita)"
},
"type": "content"
},
"style": {
"label": {
"en": "CSS Style",
"cs": "Styl CSS",
"pt-br": "Estilo CSS"
},
"type": "string"
},
"textstyle": {
"label": {
"en": "Text CSS Style",
"cs": "Textový styl CSS",
"pt-br": "Estilo CSS para o texto"
},
"type": "string"
},
"text": {
"label": {
"en": "Text",
"cs": "Text",
"pt-br": "Texto"
},
"suggested": true,
"type": "content"
},
"small": {
"label": {
"en": "Small?",
"cs": "Malý?",
"pt-br": "Caixa pequena?"
},
"suggestedvalues": [
"",
"left",
"yes",
"1"
],
"default": "0",
"type": "boolean"
},
"smallimage": {
"label": {
"en": "Small Image (left)",
"cs": "Malý obrázek (vlevo)",
"pt-br": "Imagem da caixa pequena (esquerda)"
},
"suggestedvalues": [
"none"
],
"default": "{{{image}}}",
"type": "content"
},
"smallimageright": {
"label": {
"en": "Small Image (right)",
"cs": "Malý obrázek (vpravo)",
"pt-br": "Imagem da caixa pequena (direita)"
},
"suggestedvalues": [
"none"
],
"default": "{{{imageright}}}",
"type": "content"
},
"smalltext": {
"label": {
"en": "Small Text",
"cs": "Malý text",
"pt-br": "Texto da caixa pequena"
},
"default": "{{{text}}}",
"type": "content"
}
}
}
</templatedata>