Template:Messagebox/doc: Difference between revisions

From Freephile Wiki
No edit summary
Add the examples in pre tags to show the wikitext
Line 26: Line 26:


== Visual Examples ==
== Visual Examples ==
<pre>
{{Messagebox
{{Messagebox
| text = no type, uses default (normal)
| text = no type, uses default (normal)
| style = width:50%;
| style = width:50%;
}}
}}
</pre>
{{Messagebox
| text = no type, uses default (normal)
| style = width:50%;
}}


<pre>
{{Messagebox
| type = normal
| text = Why be normal?
}}
</pre>
{{Messagebox
{{Messagebox
| type = normal
| type = normal
Line 36: Line 49:
}}
}}


<pre>
{{Messagebox
| type = success
| text = You won!
}}
</pre>
{{Messagebox
{{Messagebox
| type = success
| type = success
Line 41: Line 60:
}}
}}


<pre>
{{Messagebox
| type = warning
| text = Do not spit into the wind
}}
</pre>
{{Messagebox
{{Messagebox
| type = warning
| type = warning
Line 46: Line 71:
}}
}}


<pre>
{{Messagebox
|type = failure
|text = Something went wrong.
}}
</pre>
{{Messagebox
{{Messagebox
|type = failure
|type = failure
Line 51: Line 82:
}}
}}


<pre>
{{Messagebox
{{Messagebox
| type = forbidden
| type = forbidden
Line 56: Line 88:
}}
}}


</pre>
{{Messagebox
| type = forbidden
| text = You can't do that!
}}
<pre>
{{Messagebox
| type = restricted
| text = You must be a registered user to create or edit articles.  Contact the [[User:Freephile|WikiSysop]] for an account!
}}
</pre>
{{Messagebox
{{Messagebox
| type = restricted
| type = restricted
Line 62: Line 106:


== Making this template ==
== Making this template ==
To generate the resized images from svg
[[Image:Dialog-error.svg|20px]]
[[Image:Dialog-warning.svg|20px]]
[[Image:Dialog-ok-apply.svg|20px]]
[[Image:Dialog-information.svg|20px]]
[[Image:Dialog-cancel.svg|20px]]
[[Image:Dialog-password.svg|20px]]


The parser code (how to do switch statements) is based on the example of the Ambox template from Mediawiki
The parser code (how to do switch statements) is based on the example of the Ambox template from Mediawiki

Revision as of 08:09, 4 September 2025

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

no type, uses default (normal)



{{Messagebox
| type = normal
| text = Why be normal?
}}

Why be normal?


{{Messagebox
| type = success
| text = You won!
}}

You won!


{{Messagebox
| type = warning
| text = Do not spit into the wind
}}

Do not spit into the wind


{{Messagebox
|type = failure
|text = Something went wrong.
}}

Something went wrong.


{{Messagebox
| type = forbidden
| text = You can't do that!
}}

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

You must be a registered user to create or edit articles. Contact the 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.