Module:Userbox/doc: Difference between revisions
Appearance
Content deleted Content added
mNo edit summary |
reverted to Special:Diff/747881028 |
||
Line 1: | Line 1: | ||
⚫ | |||
{{Module rating|protected}} |
|||
⚫ | |||
{{Infobox |
|||
|name = Userbox/doc |
|||
|bodystyle = |
|||
This module does the processing for three userbox templates, {{tl|userbox}}, {{tl|userbox-2}} and {{tl|userbox-r}}. |
|||
|titlestyle = |
|||
|abovestyle = background:#cfc; |
|||
|subheaderstyle = |
|||
|title = Test Infobox |
|||
|above = Above text |
|||
|subheader = Subheader above image |
|||
|subheader2 = Second subheader |
|||
{| class="wikitable" |
|||
|imagestyle = |
|||
|- |
|||
|captionstyle = |
|||
! Template |
|||
| image = [[File:Example-serious.jpg|200px|alt=Example alt text]] |
|||
! Description |
|||
|caption = Caption displayed below Example-serious.jpg |
|||
! Examples |
|||
|- |
|||
| {{tl|userbox}} |
|||
| Makes userboxes with an id on the left-hand side, or with no id. |
|||
| {{userbox|id=id}} |
|||
{{clear}} |
|||
{{userbox}} |
|||
|- |
|||
| {{tl|userbox-2}} |
|||
| Makes userboxes with an id on both the left- and right-hand sides. |
|||
| {{userbox-2}} |
|||
|- |
|||
| {{tl|userbox-r}} |
|||
| Makes userboxes with an id on the right-hand side. |
|||
| {{userbox-r}} |
|||
⚫ | |||
To use any of these templates from a wiki page, please see the individual template pages for documentation. To generate userboxes directly from Lua, read on. |
|||
|headerstyle = background:#ccf; |
|||
|labelstyle = background:#ddf; |
|||
|datastyle = |
|||
== Generating userboxes from Lua == |
|||
|header1 = Header defined alone |
|||
| label1 = |
|||
| data1 = |
|||
|header2 = |
|||
| label2 = Label defined alone does not display (needs data, or is suppressed) |
|||
| data2 = |
|||
|header3 = |
|||
| label3 = |
|||
| data3 = Data defined alone |
|||
|header4 = All three defined (header, label, data, all with same number) |
|||
| label4 = does not display (same number as a header) |
|||
| data4 = does not display (same number as a header) |
|||
|header5 = |
|||
| label5 = Label and data defined (label) |
|||
| data5 = Label and data defined (data) |
|||
To generate a userbox directly from Lua, first load the module. |
|||
|belowstyle = background:#ddf; |
|||
|below = Below text |
|||
<source lang="lua"> |
|||
⚫ | |||
local userbox = require('Module:Userbox') |
|||
</source> |
|||
You can then run any of the three templates with the code: |
|||
<source lang="lua"> |
|||
userbox.main(functionName, args) |
|||
</source> |
|||
For {{tl|userbox}} use the function name "<code>_userbox</code>"; for {{tl|userbox-2}} use the function name "<code>_userbox-2</code>"; and for {{tl|userbox-r}} use the function name "<code>_userbox-r</code>". The <code>args</code> parameter is a table of arguments to pass to the different userbox functions. To see a list of valid arguments, please consult the individual template pages. |
Revision as of 01:44, 25 April 2017
![]() | This Lua module is used on 330,000+ pages, or roughly 1% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
This module does the processing for three userbox templates, {{userbox}}, {{userbox-2}} and {{userbox-r}}.
Template | Description | Examples | |||
---|---|---|---|---|---|
{{userbox}} | Makes userboxes with an id on the left-hand side, or with no id. |
| |||
{{userbox-2}} | Makes userboxes with an id on both the left- and right-hand sides. |
| |||
{{userbox-r}} | Makes userboxes with an id on the right-hand side. |
|
To use any of these templates from a wiki page, please see the individual template pages for documentation. To generate userboxes directly from Lua, read on.
Generating userboxes from Lua
To generate a userbox directly from Lua, first load the module.
local userbox = require('Module:Userbox')
You can then run any of the three templates with the code:
userbox.main(functionName, args)
For {{userbox}} use the function name "_userbox
"; for {{userbox-2}} use the function name "_userbox-2
"; and for {{userbox-r}} use the function name "_userbox-r
". The args
parameter is a table of arguments to pass to the different userbox functions. To see a list of valid arguments, please consult the individual template pages.