Jump to content

Template:Cmbox/doc: Difference between revisions

From ytptenniswiki
m 1 revision imported: message box templates
Line 1: Line 1:
{{Mbox templates}}
{{Documentation subpage}}
{{Documentation subpage}}
<!-- Categories go where indicated at the bottom of this page, please; interwikis go to Wikidata (see also: [[Wikipedia:Wikidata]]). -->
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
{{Cascade-protected template}}
{{Lua|Module:Message box{{\sandbox}}}}
{{high-use}}
{{Uses TemplateStyles|Module:Message box/ambox.css}}
{{Lua|Module:Message box}}
{{Mbox templates (small)}}


This is the {{tl|Cmbox}} (['''C''']ategory ['''m''']essage ['''box''']) [[WP:MTM|metatemplate]].
This is the {{tl|Cmbox}} (['''C''']ategory ['''m''']essage ['''box''']) metatemplate.


It is used to build message box templates such as {{tl|Category diffuse}} for category pages. It offers several different colours, uses default images if no image parameter is given, and it has some other features.
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:
<syntaxhighlight lang="wikitext">
<pre>
{{cmbox | text = Some text.}}
{{cmbox | text = Some text.}}
</syntaxhighlight>
</pre>


{{cmbox | text = Some text.}}
{{cmbox{{\sandbox}} | text = Some text.}}




Complex example:
Complex example:
<syntaxhighlight lang="wikitext">
<pre>
{{cmbox
{{cmbox
| type      = style
| type      = style
Line 30: Line 29:
| text      = The message body text.
| text      = The message body text.
}}
}}
</syntaxhighlight>
</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|Overpopulated category}}.
| 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|Overpopulated category}} and {{tl|Category diffuse}}.
| 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||class=skin-invert-image|52px]]
| image = [[File:Redirect arrow.svg|52px]]
| text  = type = move<br />image = <nowiki>[[File:Redirect arrow.svg|class=skin-invert-image|52px]]</nowiki><br />This image is used for {{tl|Category redirect}}.
| 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 [[spaceflight]]s.'''<br />It is populated by the {{tl|Current spaceflight}} template.
| 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:
<syntaxhighlight lang="wikitext">
<pre>
{{cmbox
{{cmbox
| name = name of the template
| 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.
}}
}}
</syntaxhighlight>
</pre>
 
'''name'''
:(Optional) Name of the template. This adds a CSS class with name <code>box-''name''</code> to the HTML element, for use by bots or scripts.


'''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.png|40px]]</nowiki></code>
::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:
<syntaxhighlight lang="wikitext">
<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 <nowiki>}}</nowiki>.  
But here is a pipe {{!}} and two end braces &lt;nowiki>}}&lt;/nowiki>.  
And now a pipe and end braces <nowiki>|}}</nowiki>.
And now a pipe and end braces &lt;nowiki>|}}&lt;/nowiki>.
</div>
</div>
}}
}}
</syntaxhighlight>
</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 [[MediaWiki:Common.css]] for most of its looks, thus it is fully skinnable.
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 [[mw:Help:Extension:ParserFunctions|parser functions]] and special characters in parameters.  
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).


===See also===
== TemplateData ==
{{Mbox templates see also}}
{{Mbox/TemplateData}}
 
<includeonly>{{Sandbox other||
<includeonly>{{Sandbox other||
<!-- Categories go below this line, please; interwikis go to Wikidata, thank you! -->
<!-- Categories below this line; interwikis at Wikidata -->
[[Category:Mbox and messagebox templates]]
[[Category:Mbox templates{{#translation:}}]]
[[Category:Category namespace templates|*]]
 
}}</includeonly>
}}</includeonly>

Revision as of 17:11, 30 March 2025

[[Category:Template documentation pages{{#translation:}}]]

Template:Uses TemplateStyles

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.}}


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.
}}


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.

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.


Special

Some other parameter combinations.


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]]
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]]
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;

textstyle

An optional CSS value used by the text cell.
For example: textstyle = text-align: center;

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>
}}


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

nebo “multi namespace message box“.", "en": "This is the specialized version of the

or \"multi-namespace message box\" meta-template.", "pt-br": "Esta é a versão especializada da meta-predefinição

, 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>