Difference between revisions of "Template:Messagebox"

From Freephile Wiki
Jump to navigation Jump to search
(mark this template with the todo template -- needs to be integrated with new Chameleon skin rather than just the freephile skin)
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
| warning    = message-warning
 
| warning    = message-warning
 
| failure      = message-failure
 
| failure      = message-failure
 +
| restricted = message-restricted
 +
| forbidden = message-forbidden
 
| normal <!-- normal = default -->
 
| normal <!-- normal = default -->
 
| #default  = message-normal
 
| #default  = message-normal
Line 15: Line 17:
 
| warning
 
| warning
 
| failure
 
| failure
 +
| restricted
 +
| forbidden
 
| normal    =    <!-- Do nothing, valid "type" -->
 
| normal    =    <!-- Do nothing, valid "type" -->
 
| #default  = <div style="text-align: center;">This message box is using an invalid "type={{{type|}}}" parameter and needs fixing. ([[:Category:templates using deprecated types|learn more]])</div><!-- Sort on namespace -->
 
| #default  = <div style="text-align: center;">This message box is using an invalid "type={{{type|}}}" parameter and needs fixing. ([[:Category:templates using deprecated types|learn more]])</div><!-- Sort on namespace -->
 
}}
 
}}
 
<noinclude>
 
<noinclude>
 +
This template is for generating nicely formatted message boxes in articles, or even other templates.
 +
 
== Usage ==
 
== Usage ==
The template takes two named parameters.  '''type''' is optional
+
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 ==
 
<pre>
 
<pre>
 
{{Messagebox
 
{{Messagebox
|type = success (or warning, failure, normal) can be left blank
+
| type = success
|text = your message content
+
| style = width:50%;
 +
| text = your message content
 
}}
 
}}
 
</pre>
 
</pre>
Line 31: Line 48:
 
For a more complex (up to 80 parameters) template, see the Infobox template [[Template_talk:Infobox]]
 
For a more complex (up to 80 parameters) template, see the Infobox template [[Template_talk:Infobox]]
  
== Examples ==
+
== Visual Examples ==
 
{{Messagebox
 
{{Messagebox
|text = no type, uses default (normal)
+
| text = no type, uses default (normal)
 +
| style = width:50%;
 
}}
 
}}
  
 
{{Messagebox
 
{{Messagebox
|type = normal
+
| type = normal
|text = Why be normal?
+
| text = Why be normal?
 
}}
 
}}
  
 
{{Messagebox
 
{{Messagebox
|type = success
+
| type = success
|text = You won!
+
| text = You won!
 
}}
 
}}
  
 
{{Messagebox
 
{{Messagebox
|type = warning
+
| type = warning
|text = Do not spit into the wind
+
| text = Do not spit into the wind
 
}}
 
}}
  
Line 56: Line 74:
 
}}
 
}}
  
 +
{{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!
 +
}}
 +
== To Do ==
 +
# <strike>Based on the existing dialog images [http://freephile.com/wiki/index.php?title=Special%3ASearch&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&search=dialog&fulltext=Advanced+search], I should add a type for "restricted" for pages with restricted authoring and or "forbidden"</strike>
 +
# {{@todo}} Improve and coordinate the CSS with the new Chameleon skin rather than just the freephile skin
  
 
== Making this template ==
 
== Making this template ==
 +
To generate the resized images from svg
 +
[[Image:Dialog-error.svg|32px]]
 +
[[Image:Dialog-warning.svg|32px]]
 +
[[Image:Dialog-ok-apply.svg?|32px]]
 +
[[Image:Dialog-information.svg|32px]]
 +
[[Image:Dialog-cancel.svg|32px]]
 +
[[Image:Dialog-password.svg|32px]]
 +
 
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
  
Line 64: Line 102:
 
The background images for the CSS are put into the images subfolder to make it easier to distinguish what is based on monobook, and what is extra
 
The background images for the CSS are put into the images subfolder to make it easier to distinguish what is based on monobook, and what is extra
 
<source lang="css">
 
<source lang="css">
.message-box {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; background-color:#EBFFEA; border:1px solid #0BD200; color:#333333; padding:8px; margin:10px;background-repeat: no-repeat;background-position: 6px 6px;}
+
.message-box {
.message-box a:link, .message-box a:active, .message-box a:visited {color:#990000;text-decoration:none;border-bottom:1px solid #cccccc;}
+
font-family: Verdana, Arial, Helvetica, sans-serif;
.message-box a:hover {color:#990000;text-decoration:none;border-bottom:1px solid #990000;}
+
font-size: 11px;
.message-success {font-weight: bold;border:1px solid #8FD500; background-color:#F2FFD7; background-image: url(images/check.gif);padding-left: 28px;}
+
background-color:#EBFFEA;
.message-failure {font-weight: bold; color: #990000; border:1px solid #DD3C10; background-color:#FFEBE8; background-image: url(images/wrong.gif);padding-left: 28px;}
+
border:1px solid #0BD200;
.message-warning {font-weight: bold;color:#FF6633;border: 1px solid #ff9900; background-color:#fbf8c7; background-image: url(images/warning_sign.gif);padding-left: 28px;}
+
color:#333333;
.message-box .message-normal {font-weight:normal;color: #333;}
+
padding:8px;
 +
margin:10px;
 +
background-repeat: no-repeat;
 +
background-position: 6px 6px;
 +
}
 +
.message-box a:link, .message-box a:active, .message-box a:visited {
 +
color:#990000;
 +
text-decoration:none;
 +
border-bottom:1px solid #cccccc;
 +
}
 +
.message-box a:hover {
 +
color:#990000;
 +
text-decoration:none;
 +
border-bottom:1px solid #990000;
 +
}
 +
.message-success {
 +
font-weight: bold;
 +
border:1px solid #8FD500;
 +
background-color:#F2FFD7;
 +
background-image: url(images/32px-Dialog-ok-apply.svg.png);
 +
padding-left: 32px;
 +
}
 +
.message-failure {
 +
font-weight: bold;
 +
color: #990000;
 +
border:1px solid #DD3C10;
 +
background-color:#FFEBE8;
 +
background-image: url(images/32px-Dialog-error.svg.png);
 +
padding-left: 32px;
 +
}
 +
.message-warning {
 +
font-weight: bold;
 +
color:#FF6633;
 +
border: 1px solid #ff9900;
 +
background-color:#fbf8c7;
 +
background-image: url(images/32px-Dialog-warning.svg.png);
 +
padding-left: 32px;
 +
}
 +
.message-box .message-normal {
 +
font-weight:normal;
 +
color: #333;
 +
background-image: url(images/32px-Dialog-information.svg.png);
 +
padding-left: 32px;
 +
}
 
</source>
 
</source>
 
</noinclude>
 
</noinclude>
  
 
[[Category:Templates using ParserFunctions]]
 
[[Category:Templates using ParserFunctions]]

Latest revision as of 10:26, 31 January 2016

{{{text}}}


This template is for generating nicely formatted message boxes in articles, or even other templates.

Usage[edit source]

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

{{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 source]

no type, uses default (normal)

Why be normal?

You won!

Do not spit into the wind

You kissed your cousin

You can't do that!

You must be a registered user to create or edit articles. Contact the WikiSysop for an account!

To Do[edit source]

  1. Based on the existing dialog images [1], I should add a type for "restricted" for pages with restricted authoring and or "forbidden"
  2. Gedit.svg todo Improve and coordinate the CSS with the new Chameleon skin rather than just the freephile skin

Making this template[edit source]

To generate the resized images from svg Dialog-error.svg Dialog-warning.svg 32px Dialog-information.svg Dialog-cancel.svg Dialog-password.svg

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

The following CSS is added to skins/freephile/freephile_template.css to make this template complete

The background images for the CSS are put into the images subfolder to make it easier to distinguish what is based on monobook, and what is extra

.message-box {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
background-color:#EBFFEA;
border:1px solid #0BD200;
color:#333333;
padding:8px;
margin:10px;
background-repeat: no-repeat;
background-position: 6px 6px;
}
.message-box a:link, .message-box a:active, .message-box a:visited {
color:#990000;
text-decoration:none;
border-bottom:1px solid #cccccc;
}
.message-box a:hover {
color:#990000;
text-decoration:none;
border-bottom:1px solid #990000;
}
.message-success {
font-weight: bold;
border:1px solid #8FD500;
background-color:#F2FFD7;
background-image: url(images/32px-Dialog-ok-apply.svg.png);
padding-left: 32px;
}
.message-failure {
font-weight: bold;
color: #990000;
border:1px solid #DD3C10;
background-color:#FFEBE8;
background-image: url(images/32px-Dialog-error.svg.png);
padding-left: 32px;
}
.message-warning {
font-weight: bold;
color:#FF6633;
border: 1px solid #ff9900;
background-color:#fbf8c7;
background-image: url(images/32px-Dialog-warning.svg.png);
padding-left: 32px;
}
.message-box .message-normal {
font-weight:normal;
color: #333;
background-image: url(images/32px-Dialog-information.svg.png);
padding-left: 32px;
}