Anonymous
×
Create a new article
Write your page title here:
We currently have 15 articles on TwistedFates Database. Type your article name above or click on one of the titles below and start writing!



TwistedFates Database
15Articles

Module:Message box/doc: Difference between revisions

wikip>GKFX
Remove {{high-use}} as now redundant to {{used in system}}
 
m 1 revision imported
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude><!--
-->{{#ifeq:{{SUBPAGENAME}}|doc||{{Documentation subpage}}}}<!--
--><languages /><!--
--></noinclude>{{#switch:<translate></translate>
| =
<includeonly>{{Languages|Module:Message box/doc}}</includeonly>
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
<!-- {{Shared Template Warning|Module:Message box}} -->
{{Used in system}}
{{Used in system}}
{{module rating|r}}
{{module rating|p}}
{{module rating|p}}
{{Lua|Module:Message box/configuration|Module:No globals|Module:Yesno|Module:Arguments|Module:Category handler}}
{{Lua|Module:Message box/configuration|Module:Arguments|Module:Yesno}}
{{Uses TemplateStyles
| Module:Message box/ambox.css
| Module:Message box/cmbox.css
| Module:Message box/fmbox.css
| Module:Message box/imbox.css
| Module:Message box/ombox.css
| Module:Message box/tmbox.css
}}


This is a meta-module that implements the message box templates {{tl|mbox}}, {{tl|ambox}}, {{tl|cmbox}}, {{tl|fmbox}}, {{tl|imbox}}, {{tl|ombox}}, and {{tl|tmbox}}. It is intended to be used from Lua modules, and should not be used directly from wiki pages. If you want to use this module's functionality from a wiki page, please use the individual message box templates instead.
<translate><!--T:1--> This is a meta-module that implements the message box templates <tvar name=1>{{separated entries|{{tlx|mbox}}|{{tlx|ambox}}|{{tlx|cmbox}}|{{tlx|fmbox}}|{{tlx|imbox}}|{{tlx|ombox}}|{{tlx|tmbox}}|separator=<nowiki/>{{int|lang={{TRANSLATIONLANGUAGE}}|comma-separator}}<nowiki/>|conjunction=<nowiki/>{{int|lang={{TRANSLATIONLANGUAGE}}|and}}{{int|lang={{TRANSLATIONLANGUAGE}}|word-separator}}<nowiki/>}}</tvar>.</translate>
<translate><!--T:2--> It is intended to be used from Lua modules, and should not be used directly from wiki pages.</translate>
<translate><!--T:3--> If you want to use this module's functionality from a wiki page, please use the individual message box templates instead.</translate>


== Usage ==
<translate>
== Usage == <!--T:4-->


<!--T:5-->
To use this module from another Lua module, first you need to load it.
To use this module from another Lua module, first you need to load it.
</translate>


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 13: Line 35:
</syntaxhighlight>
</syntaxhighlight>


To create a message box, use the <code>main</code> function. It takes two parameters: the first is the box type (as a string), and the second is a table containing the message box parameters.
<translate><!--T:6--> To create a message box, use the <tvar name=1><code>main</code></tvar> function.</translate>
<translate><!--T:7--> It takes two parameters:</translate>
 
{{Unordered list
|1=
<translate><!--T:8--> the first is the box type (as a string).</translate>
|2=
<translate><!--T:9--> the second is a table containing the message box parameters.</translate>
}}


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local box = messageBox.main( boxType, {
local box = messageBox.main( boxType, {
    param1 = param1,
param1 = param1,
    param2 = param2,
param2 = param2,
    -- More parameters...
-- <translate nowrap><!--T:10--> More parameters...</translate>
})
})
</syntaxhighlight>
</syntaxhighlight>


<translate>
<!--T:11-->
There are seven available box types:
There are seven available box types:
</translate>


{| class="wikitable"
{{(!}} class="wikitable"
! Box type !! Template !! Purpose
! <translate><!--T:12--> Box type</translate>
|-
! <translate><!--T:13--> Template</translate>
| <code>mbox</code> || {{tl|mbox}} || For message boxes to be used in multiple namespaces
! <translate><!--T:14--> Purpose</translate>
|-
{{!}}-
| <code>ambox</code> || {{tl|ambox}} || For article message boxes
{{!}} <code>mbox</code>
|-
{{!}} {{tlx|mbox}}
| <code>cmbox</code> || {{tl|cmbox}} || For category message boxes
{{!}} <translate><!--T:15--> For message boxes to be used in multiple namespaces</translate>
|-
{{!}}-
| <code>fmbox</code> || {{tl|fmbox}} || For interface message boxes
{{!}} <code>ambox</code>
|-
{{!}} {{tlx|ambox}}
| <code>imbox</code> || {{tl|imbox}} || For file namespace message boxes
{{!}} <translate><!--T:16--> For article message boxes</translate>
|-
{{!}}-
| <code>tmbox</code> || {{tl|tmbox}} || For talk page message boxes
{{!}} <code>cmbox</code>
|-
{{!}} {{tlx|cmbox}}
| <code>ombox</code> || {{tl|ombox}} || For message boxes in other namespaces
{{!}} <translate><!--T:17--> For category message boxes</translate>
|}
{{!}}-
{{!}} <code>fmbox</code>
{{!}} {{tlx|fmbox}}
{{!}} <translate><!--T:18--> For interface message boxes</translate>
{{!}}-
{{!}} <code>imbox</code>
{{!}} {{tlx|imbox}}
{{!}} <translate><!--T:19--> For file namespace message boxes</translate>
{{!}}-
{{!}} <code>tmbox</code>
{{!}} {{tlx|tmbox}}
{{!}} <translate><!--T:20--> For talk page message boxes</translate>
{{!}}-
{{!}} <code>ombox</code>
{{!}} {{tlx|ombox}}
{{!}} <translate><!--T:21--> For message boxes in other namespaces</translate>
{{!)}}


<translate>
<!--T:22-->
See the template page of each box type for the available parameters.
See the template page of each box type for the available parameters.


== Usage from #invoke ==
== Usage from <tvar name=1><code>#invoke</code></tvar> == <!--T:23-->
</translate>


As well as the <code>main</code> function, this module has separate functions for each box type. They are accessed using the code <code><nowiki>{{#invoke:Message box|mbox|...}}</nowiki></code>, <code><nowiki>{{#invoke:Message box|ambox|...}}</nowiki></code>, etc. These will work when called from other modules, but they access code used to process arguments passed from #invoke, and so calling them will be less efficient than calling <code>main</code>.
<translate><!--T:24--> As well as the <tvar name=1><code>main</code></tvar> function, this module has separate functions for each box type.</translate>
<translate><!--T:25--> They are accessed using the code <tvar name=1>{{magic word|ext=Scribunto|nowrap=1|code=1|#invoke|[[Module:Message box|Message box]]<nowiki>|mbox|...</nowiki>}}</tvar>, <tvar name=2>{{tlc|#invoke:Message box|ambox|...}}</tvar>, etc.</translate>
<translate><!--T:26--> These will work when called from other modules, but they access code used to process arguments passed from <tvar name=1>{{tlc|#invoke:...}}</tvar>, and so calling them will be less efficient than calling <tvar name=2><code>main</code></tvar></translate>.


== Technical details ==
<translate>
== Technical details == <!--T:27-->


The module uses the same basic code for each of the templates listed above; the differences between each of them are configured using the data at [[Module:Message box/configuration]]. Here are the various configuration options and what they mean:
<!--T:28-->
The module uses the same basic code for each of the templates listed above; the differences between each of them are configured using the data at <tvar name=1>[[Module:Message box/configuration]]</tvar>.
</translate>


* <code>types</code> – a table containing data used by the type parameter of the message box. The table keys are the values that can be passed to the type parameter, and the table values are tables containing the class and the image used by that type.
<includeonly>{{Sandbox other||
* <code>default</code> – the type to use if no value was passed to the type parameter, or if an invalid value was specified.
<!-- Categories below this line; interwikis at Wikidata -->
* <code>showInvalidTypeError</code> – whether to show an error if the value passed to the type parameter was invalid.
[[Category:Modules{{#translation:}}]]
* <code>allowBlankParams</code> – usually blank values are stripped from parameters passed to the module. However, whitespace is preserved for the parameters included in the allowBlankParams table.
}}</includeonly><noinclude>
* <code>allowSmall</code> – whether a small version of the message box can be produced with "small=yes".
[[Category:Module documentation pages{{#translation:}}]]
* <code>smallParam</code> – a custom name for the small parameter. For example, if set to "left" you can produce a small message box using "small=left".
</noinclude>
* <code>smallClass</code> – the class to use for small message boxes.
| #default=
* <code>substCheck</code> – whether to perform a subst check or not.
  {{#invoke:Template translation|renderTranslatedTemplate|template=Module:Message box/doc|noshift=1|uselang={{int:lang}}}}
* <code>classes</code> – an array of classes to use with the message box.
}}
* <code>imageEmptyCell</code> – whether to use an empty {{tag|td}} cell if there is no image set. This is used to preserve spacing for message boxes with a width of less than 100% of the screen.
* <code>imageEmptyCellStyle</code> – whether empty image cells should be styled.
* <code>imageCheckBlank</code> – whether "image=blank" results in no image being displayed.
* <code>imageSmallSize</code> – usually, images used in small message boxes are set to 30x30px. This sets a custom size.
* <code>imageCellDiv</code> – whether to enclose the image in a div enforcing a maximum image size.
* <code>useCollapsibleTextFields</code> – whether to use text fields that can be collapsed, i.e. "issue", "fix", "talk", etc. Currently only used in ambox.
* <code>imageRightNone</code> – whether imageright=none results in no image being displayed on the right-hand side of the message box.
* <code>sectionDefault</code> – the default name for the "section" parameter. Depends on <code>useCollapsibleTextFields</code>.
* <code>allowMainspaceCategories</code> – allow categorisation in the main namespace.
* <code>templateCategory</code> – the name of a category to be placed on the template page.
* <code>templateCategoryRequireName</code> – whether the <code>name</code> parameter is required to display the template category.
* <code>templateErrorCategory</code> – the name of the error category to be used on the template page.
* <code>templateErrorParamsToCheck</code> – an array of parameter names to check. If any are absent, the <code>templateErrorCategory</code> is applied to the template page.

Latest revision as of 22:30, 26 March 2023

<languages />

Lua error: callParserFunction: function "#translation" was not found.

This is a meta-module that implements the message box templates {{mbox}}, {{ambox}}, {{cmbox}}, {{fmbox}}, {{imbox}}, {{ombox}} and {{tmbox}}. It is intended to be used from Lua modules, and should not be used directly from wiki pages. If you want to use this module's functionality from a wiki page, please use the individual message box templates instead.

Usage

To use this module from another Lua module, first you need to load it.

local messageBox = require('Module:Message box')

To create a message box, use the main function. It takes two parameters:

  • the first is the box type (as a string).
  • the second is a table containing the message box parameters.
local box = messageBox.main( boxType, {
	param1 = param1,
	param2 = param2,
	-- More parameters...
})

There are seven available box types:

Box type Template Purpose
mbox {{mbox}} For message boxes to be used in multiple namespaces
ambox {{ambox}} For article message boxes
cmbox {{cmbox}} For category message boxes
fmbox {{fmbox}} For interface message boxes
imbox {{imbox}} For file namespace message boxes
tmbox {{tmbox}} For talk page message boxes
ombox {{ombox}} For message boxes in other namespaces

See the template page of each box type for the available parameters.

Usage from #invoke

As well as the main function, this module has separate functions for each box type. They are accessed using the code {{#invoke:Message box|mbox|...}}, {{#invoke:Message box|ambox|...}}, etc. These will work when called from other modules, but they access code used to process arguments passed from {{#invoke:...}}, and so calling them will be less efficient than calling main.

Technical details

The module uses the same basic code for each of the templates listed above; the differences between each of them are configured using the data at Module:Message box/configuration.