User:Johan G/Messagebox: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Extending)
(Notice → note)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
{| <!-- Begin box -->  
{{#switch:  <!-- Is the box type and box style parameters valid? (Show stopper)
|<!-- Begin text cell -->  
-->{{#switch: {{{box|top}}}  <!-- Checking box format parameter -->
'''{{{title|<span style="color:red;">{{tl|messagebox}}: Missing parameter: title</span>}}}''' {{#ifeq: {{lc: {{{one-liner|}}} }}
  | box
   | true
  | section
   | &emsp; <!-- If one-liner = true add 1 em space between title and text. -->
  | top =
  | {{-}} <!-- If one-liner != true add break between title and text. -->
 
  | #default =
  {{#if: {{{box-style|}}}  <!-- Was a custom box style used? -->
  |  <!-- Yes, ignore -->
 
  | <!-- No, and the box type is not valid -->
  box not ok,
  }}
}}<!--
-->{{#switch: {{{style|note}}} <!-- Checking box style parameter -->
  | speedy
  | warning
  | caution
  | note
  | tip
  | protected
  | neutral =
 
   | #default =
   {{#if: {{{box-style|}}} <!-- Was a custom box style used? -->
  |  <!-- Yes, ignore -->
 
  |  <!-- No, and the box style is not valid -->
  style not ok
   }}
   }}
{{{text|<span style="color:red;">{{tl|messagebox}}: Missing parameter: text</span>}}} <!-- Need to start at a new line in case there are wiki markup sensitive to that, e.g tables and headings -->
}}
<!-- End text cell -->
| box not ok, =
|}<!-- End box -->
invalid box format!
| style not ok =
invalid box style!
| box not ok,style not ok =
box format and style invalid!
| #default =
box format and style valid
}}
 
{| class="wikitable"  <!-- Begin box -->
|
{{#switch: {{lc: {{{box|top}}} }}  <!-- What box format? -->
| box =
box
| section =
section
| top
| #default =
{{#ifeq: {{lc: {{{box|top}}} }} | top  <!-- Is there an unspecified or valid box format specified? -->
  |  <!-- Yes, the type of box is unspecified or a valid type of box is specified -->
  top
  |  <!-- No, an invalid type of box is specified -->
  invalid box format!
}}
}};<!--
-->{{#switch: {{lc: {{{style|note}}} }<!-- Which colours to use? -->
| speedy =
speedy
| warning    =
warning
| caution  =
caution
| tip      =
tip
| protected =
protected
| neutral =
neutral
| note
| #default  =
{{#ifeq: {{{style|note}}} | note  <!-- Is there an unspecified or valid type of box specified? -->
  |  <!-- Yes, the box style is unspecified or a valid box style is specified -->
  note
  |  <!-- No, an invalid box style is specified -->
  invalid box style!
}}
}};{{User:Johan G/Messagebox/content
| title      = {{{title|}}}
| text        = {{{text|}}}
| style      = {{{style|}}}
| one-liner  = {{{one-liner|}}}
| image      = {{{image|}}}
| image-width = {{{image-width|}}}
| box        = {{{box|top}}}
| text-style  = {{{text-style|}}}
| image-style = {{{image-style|}}}
}}
|}<!-- End box


<!-- Snippet with automatic categorisation -->
--><!-- Snippet with automatic categorisation
<includeonly>{{#switch: {{{nocat|}}}
 
--><includeonly>{{#switch: {{{nocat|true}}}
   | true =
   | true =
   | false = [[:Category:Templates using messagebox meta template]][[:Category:Messagebox templates]]
   | false = [[:Category:Templates using messagebox meta template]][[:Category:Messagebox templates]]
   | #default = {{template other|[[:Category:Templates using messagebox meta template]][[:Category:Messagebox templates]]}}
   | #default = {{template other|[[:Category:Templates using messagebox meta template]][[:Category:Messagebox templates]]}}
   }}</includeonly><noinclude>
   }}</includeonly><!-- End template
 
--><noinclude>
{{Informative template|1=
{{Informative template|1=
== Goal ==
== Goal ==
Line 25: Line 108:
== Usage ==
== Usage ==
  <nowiki>{{</nowiki>'''messagebox'''
  <nowiki>{{</nowiki>'''messagebox'''
  <nowiki>|</nowiki> title      =  
  <nowiki>|</nowiki> ''title''       =  
  <nowiki>|</nowiki> text        =  
  <nowiki>|</nowiki> text        =  
   
   
  <nowiki>|</nowiki> ''box        =''  
  <nowiki>|</nowiki> ''style''       =
  <nowiki>|</nowiki> ''style      =''  
  <nowiki>|</nowiki> ''one-liner''   =
  <nowiki>|</nowiki> ''one-liner  =''  
  <nowiki>|</nowiki> ''image''       =
  <nowiki>|</nowiki> ''image       =''  
  <nowiki>|</nowiki> ''image-width'' =
  <nowiki>|</nowiki> ''image-width =''  
  <nowiki>|</nowiki> ''box''         =
   
   
  <nowiki>|</nowiki> ''box-style  =''
  <nowiki>|</nowiki> ''box-style''   =  
  <nowiki>|</nowiki> ''text-style =''  
  <nowiki>|</nowiki> ''image-style'' =
  <nowiki>|</nowiki> ''image-style =''  
  <nowiki>|</nowiki> ''text-style'' =
   
   
  <nowiki>|</nowiki> ''page        =''
  <nowiki>|</nowiki> ''page''       =  
  <nowiki>|</nowiki> ''nocat      =''
  <nowiki>|</nowiki> ''nocat''       =  
  <nowiki>}}</nowiki>
  <nowiki>}}</nowiki>


=== Mandatory parameters ===
=== Main parameters ===
;title:  Title for the messagebox that will be shown in bold, for example '''Danger''', '''Warning''', '''Caution''', '''Cleanup''', '''Note''', '''Notice''', '''Tip''', '''Hint''', '''Protected''' etc.
; title:  Optional alternative title for the messagebox that will be shown in bold, for example '''Danger''', '''Warning''', '''Caution''', '''Cleanup''', '''Note''', '''Notice''', '''Tip''', '''Hint''', '''Protected''', '''Nominated for deletion''' etc.  Defaults to '''Notice'''.


;text:  Text to be shown in the messagebox.
; text:  Text to be shown in the messagebox.


=== Parameters affecting the appearence ===
=== Parameters affecting the appearance ===
Optional parameters affecting the appearance of the messagebox.
Optional parameters affecting the appearance of the messagebox.


;boxWill override the box format.  Valid values are '''box''', '''top''' and '''section'''.  The defaults are '''box''' for the talk namespaces and the category namespace, and '''top''' for any other namespace.
; styleStyle of the messagebox.  Valid values are '''speedy''', '''warning''', '''caution''', '''note''', '''tip''', '''protected''' and '''neutral'''. Defaults to '''notice'''.


;styleStyle of the messagebox.  Valid values are '''immediate''', '''danger''', '''caution''', '''notice''', '''tip''' and '''protected'''. Defaults to '''notice'''.
; one-linerMakes the messagebox a one-liner if not empty.


;one-linerMakes the dialogue a one-liner if '''one-liner=true'''.
; imageImage or icon to use excluding the '''File:''' namespace prefix, for example '''Cleanup.png'''.  Instead of an image name a shortcut can be used.  When using the shortcuts the icons will automatically get the right colour for the style.  Valid icon shortcuts are: '''/!\''', '''(!)''', '''(?)''', '''(i)''', '''(x)''' and '''U''' (for padlock).


;image:  Image or icon to use excluding the '''File:''' namespace prefix, for example '''image=Cleanup.png'''Instead of an image name a shortcut can be used.  When using the shortcuts the icons will automatically get the right colour for the style.  Valid icon shortcuts are: '''/!\''', '''(!)''', '''(?)''', '''(i)''', '''(x)''' and '''U''' (for padlock).
; image-widthWidth of the image in pixelsDefaults to 40 pixels or for one-liners 24 pixels.


;image-widthWidth of the imageDefaults to 40 pixels or for one-liners 24 pixels.
; boxWill override the box formatValid values are '''box''', '''top''' and '''section'''.  The defaults are '''box''' for the talk namespaces and the category namespace, and '''top''' for any other namespace.


=== CSS Style parameters ===
=== CSS Style parameters ===
Optional parameters allowing cascading style sheet (CSS) style attributes to be used.  These will override the style of the messagebox.  Use sparingly and only when needed.
Optional parameters allowing cascading style sheet (CSS) style attributes to be used.  These will override the style of the messagebox.  Use sparingly and only when needed.


;box-style: CSS attributes applied to the box.
; box-style: CSS attributes applied to the box.


;text-style:  CSS attributes applied to the text cell.
; text-style:  CSS attributes applied to the text cell.


;image-style:  CSS attributes applied to the image cell.
; image-style:  CSS attributes applied to the image cell.


=== Parameters for demonstration and testing ===
=== Parameters for demonstration and testing ===
Optional parameters for demonstration and testing.
Optional parameters for demonstration and testing.


;page:  Wiki page.  Use <code><nowiki>page = {{{page|}}}</nowiki></code> to forward this behaviour to a template.
; page:  Wiki page.  Use <code><nowiki>page = {{{page|}}}</nowiki></code> to forward this behaviour to a template.


;nocat:  If '''nocat=true''' pages are not categorized, if '''nocat=false''' pages are always categorized, and if '''nocat''' is empty or undefined only pages in the template namespace are categorised.
; nocat:  If '''nocat=true''' pages are not categorized, if '''nocat=false''' pages are always categorized, and if '''nocat''' is empty or undefined only pages in the template namespace are categorised.
: Do ''not'' forward this parameter to a template for category suppression, instead use the techniques discussed in [[#Category suppression|Category suppression]] below.
: Do ''not'' forward this parameter to a template for category suppression, instead use the techniques discussed in [[#Category suppression|Category suppression]] below.


Line 82: Line 165:
Where one of the "other" templates are sufficient, a way to add a '''nocat''' parameter working in a similar way as in {{tl|category handler}} to a template is to do as in the below example:
Where one of the "other" templates are sufficient, a way to add a '''nocat''' parameter working in a similar way as in {{tl|category handler}} to a template is to do as in the below example:


  <nowiki>...{{#switch: {{nocat|}}
  <nowiki>...{{#switch: {{[nocat|}}}
| true =                                                  <!-- Will not categorise a page -->
| true =                                                  <!-- Will not categorise a page -->
| false = [[Category:Some category]]                      <!-- Will always categorise a page -->
| false = [[Category:Some category]]                      <!-- Will always categorise a page -->
Line 92: Line 175:


== Related templates ==
== Related templates ==
* [[User:Johan G/Messagebox/box format]]
* [[User:Johan G/Messagebox/content]]
* [[User:Johan G/Messagebox/icon]]
* [[User:Johan G/Messagebox/format]]
* [[User:Johan G/Messagebox/style]]
* [[User:Johan G/Messagebox/style]]



Latest revision as of 02:57, 2 June 2014

box format and style valid

top;note;top;messagebox/icon: no image;multiliner text padding;;

The following template description is not displayed when the template is inserted in an article.

Goal

This template is a meta template for messagebox templates of various kinds.

Adding this template to a page in the template namespace will automatically add Category:Messagebox templates and the hidden Category:Templates using messagebox meta template to that page.

Usage

{{messagebox
| title       = 
| text        = 

| style       = 
| one-liner   = 
| image       = 
| image-width = 
| box         = 

| box-style   = 
| image-style =
| text-style  = 

| page        = 
| nocat       = 
}}

Main parameters

title
Optional alternative title for the messagebox that will be shown in bold, for example Danger, Warning, Caution, Cleanup, Note, Notice, Tip, Hint, Protected, Nominated for deletion etc. Defaults to Notice.
text
Text to be shown in the messagebox.

Parameters affecting the appearance

Optional parameters affecting the appearance of the messagebox.

style
Style of the messagebox. Valid values are speedy, warning, caution, note, tip, protected and neutral. Defaults to notice.
one-liner
Makes the messagebox a one-liner if not empty.
image
Image or icon to use excluding the File: namespace prefix, for example Cleanup.png. Instead of an image name a shortcut can be used. When using the shortcuts the icons will automatically get the right colour for the style. Valid icon shortcuts are: /!\, (!), (?), (i), (x) and U (for padlock).
image-width
Width of the image in pixels. Defaults to 40 pixels or for one-liners 24 pixels.
box
Will override the box format. Valid values are box, top and section. The defaults are box for the talk namespaces and the category namespace, and top for any other namespace.

CSS Style parameters

Optional parameters allowing cascading style sheet (CSS) style attributes to be used. These will override the style of the messagebox. Use sparingly and only when needed.

box-style
CSS attributes applied to the box.
text-style
CSS attributes applied to the text cell.
image-style
CSS attributes applied to the image cell.

Parameters for demonstration and testing

Optional parameters for demonstration and testing.

page
Wiki page. Use page = {{{page|}}} to forward this behaviour to a template.
nocat
If nocat=true pages are not categorized, if nocat=false pages are always categorized, and if nocat is empty or undefined only pages in the template namespace are categorised.
Do not forward this parameter to a template for category suppression, instead use the techniques discussed in Category suppression below.

Category suppression

In cases where a template using {{messagebox}} is automatically categorising pages it is highly recommended to use {{messagebox}} together with a namespace template to suppress categorisation if a template is used on other pages than the intended ones, like for example in lists of templates. Some common namespace templates are for example {{category handler}}, {{main other}}, {{talk other}} and {{category other}}.

Where one of the "other" templates are sufficient, a way to add a nocat parameter working in a similar way as in {{category handler}} to a template is to do as in the below example:

...{{#switch: {{[nocat|}}}
| true =                                                   <!-- Will not categorise a page -->
| false = [[Category:Some category]]                       <!-- Will always categorise a page -->
| #default = {{main other | [[Category:Same category]] }}  <!-- Will categorise a page only if it is in the main namespace, the article namespace. -->
}}...

Examples

Examples using different options.

Related templates