Template:Messagebox
This template is for generating nicely formatted message boxes in articles, or even other templates.
Usage[edit]
The template takes three named parameters that can be given in any order.
- text
- (required) is the message
- type
- (optional) determines the presentation using pre-defined styling. One of
- success - to indicate what success means
- warning - to alert the user about preventing problems
- failure - to dialog about when something fails
- restricted - shows the keys graphic, to advise of a restricted access area or restricted authoring
- forbidden - for messages about policies about things you should not do
- normal (default)
- style
- (optional) is CSS that will be passed through.
Literal Code Example[edit]
{{Messagebox
| type = success
| style = width:50%;
| text = your message content
}}
For a more complex (up to 80 parameters) template, see the Infobox template Template_talk:Infobox
Visual Examples[edit]
{{Messagebox
| text = no type, uses default (normal)
| style = width:50%;
}}
{{Messagebox
| type = normal
| text = Why be normal?
}}
{{Messagebox
| type = success
| text = You won!
}}
{{Messagebox
| type = warning
| text = Do not spit into the wind
}}
{{Messagebox
|type = failure
|text = Something went wrong.
}}
{{Messagebox
| type = forbidden
| text = You can't do that!
}}
{{Messagebox
| type = restricted
| text = You must be a registered user to create or edit articles. Contact the [[User:Freephile|WikiSysop]] for an account!
}}
Making this template[edit]
The parser code (how to do switch statements) is based on the example of the Ambox template from Mediawiki
The CSS is added to Template:Messagebox/styles.css to make this template complete by incorporating the TemplateStyles extension.
Messagebox is for creating call-outs of text in a bordered box. This visually distinguishes the text from other content on the page. There are multiple "types" that are predefined - basically red, yellow green.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Type of box | type | Type determines the decoration of the message box
| String | optional |
| CSS markup | style | Add CSS if desired. This will be passed to the "style" attribute of the containing div.
| String | optional |
| Your message | text | The text (and wiki markup) displayed in the message box. | String | required |
| The above documentation is transcluded from Template:Messagebox/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |