User:Johan G/Messagebox: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (small fixes)
m (Test for valid box type and style; etc)
Line 1: Line 1:
{{#switch:  <!-- Is the box type and box style parameters valid? (Show stopper)
-->{{#switch: {{{box|top}}}  <!-- Checking box type parameter -->
  | box
  | section
  | top =
 
  | #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|notice}}}  <!-- Checking box style parameter -->
  | speedy
  | warning
  | caution
  | notice
  | 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
  }}
}}
| box not ok, =
invalid box type!
| style not ok =
invalid box style!
| box not ok,style not ok =
box type and style invalid!
| #default =
box type and style valid
}}
{| class="wikitable"  <!-- Begin box -->  
{| class="wikitable"  <!-- Begin box -->  
|
|
Line 12: Line 53:
   top
   top
   |  <!-- No, an invalid type of box is specified -->
   |  <!-- No, an invalid type of box is specified -->
   invalid box type
   invalid box type!
  }}
  }}
}};<!--
}};<!--
Line 34: Line 75:
   notice
   notice
   |  <!-- No, an invalid box style is specified -->
   |  <!-- No, an invalid box style is specified -->
   invalid box style
   invalid box style!
  }}
  }}
}};<!--
}};<!--
Line 70: Line 111:
     {{{image|image}}}
     {{{image|image}}}
     |  <!-- No the specified image does not exist -->
     |  <!-- No the specified image does not exist -->
     non-existent image
     non-existent image!
   }}
   }}
   }}
   }}
   |  <!-- No, an invalid custom image width was specified -->
   |  <!-- No, an invalid custom image width was specified -->
   custom image width not a number
   custom image width not a number!
  }}
  }}
  |  <!-- No there is no image -->
  |  <!-- No there is no image -->

Revision as of 01:34, 26 May 2014

box type and style valid

top;notice;no image;multiliner text padding;title;text

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        = 

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

| 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 etc. Defaults to Notice.
text
Text to be shown in the messagebox.

Parameters affecting the appearance

Optional parameters affecting the appearance of the messagebox.

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.
style
Style of the messagebox. Valid values are speedy, warning, caution, notice, 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.

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