Pumunta sa nilalaman

Module:Message box/doc

Mula sa Wikipedia, ang malayang ensiklopedya

Patungkol

Isa itong meta module na gumagawa sa mga padron na kahong pangmensahe (message box): {{mbox}}, {{ambox}}, {{cmbox}}, {{fmbox}}, {{imbox}}, {{ombox}}, at {{tmbox}}. Ginawa ito upang gamitin lang sa ibang mga module ng Lua, at hindi para gamitin nang direkta sa mga pahina ng wiki. Kung gusto niyong gamitin ang kakayahan ng module na ito sa isang pahina ng wiki, pakigamkt po ang mga indibidwal na kahong pangmensahe.

Paggamit

Para magamit ang module na ito sa isang module ng Lua, dapat i-load mo muna ito.

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

Para makagawa ng isang kahong pangmensahe, gamitin ang main function. May dalawang parameter ito: ang uri ng kahon (sa string), at ang talahanayan na naglalaman ng mga parameter ng kahong pangmensahe.

local box = messageBox.main( boxType, {
    param1 = param1,
    param2 = param2,
    -- at iba pang mga parameter...
})

May pitong magagamit na uri ng kahon:

Uri ng kahon Padron Gamit
mbox {{mbox}} Para sa mga kahong pangmensaheng gagamitin sa maraming namespace.
ambox {{ambox}} Para sa mga kahong pangmensahe sa mga artikulo.
cmbox {{cmbox}} Para sa mga kahong pangmensahe sa mga kategorya.
fmbox {{fmbox}} Para sa mga kahong pangmensahe sa interface.
imbox {{imbox}} Para sa mga kahong pangmensahe sa file namespace.
tmbox {{tmbox}} Para sa mga kahong pangmensahe sa mga pahina ng usapan.
ombox {{ombox}} Para sa mga kahong pangmensahe sa mga namespace na hindi nabanggit dito.

Tingnan ang dokumentasyon ng mga indibidwal na padron para sa mas detalyadong impormasyon.

Paggamit sa #invoke

Bukod sa main function, may mga hiwalay na function ang module na ito para sa bawat uri ng kahon. Maa-access sila gamit ang code na {{#invoke:Message box|mbox|...}}, {{#invoke:Message box|ambox|...}}, atbp. Gagana sila kapag tinawag sa ibang mga module, pero kaya nilang ma-access ang code na ginamit para iproseso ang mga argumentong pinasa sa #invoke, kaya naman mas mahina ito kesa sa pagtawag sa main.

Mga detalyeng teknikal

Ginagamit ng module ang parehong basic code para sa bawat padron na nakalista sa taas; makikita at masasaayos sa Module:Message box/configuration ang kani-kanilang pagkakaiba. Heto ang iba't-ibang mga pagsasaayos at kung ano-ano ang ibig sabihin nila:

  • types – talahanayan na naglalaman ng data na ginagamit ng |type= parameter ng kahong pangmensahe. Mga value ang mga key ng talahanayan na maipapasa sa |type=, at talahanayan ang mga value na naglalaman ng class at ang image na ginamit ng uri na yon.
  • default – the type to use if no value was passed to the type parameter, or if an invalid value was specified.
  • showInvalidTypeError – whether to show an error if the value passed to the type parameter was invalid.
  • allowBlankParams – usually blank values are stripped from parameters passed to the module. However, whitespace is preserved for the parameters included in the allowBlankParams table.
  • allowSmall – whether a small version of the message box can be produced with "small=yes".
  • smallParam – a custom name for the small parameter. For example, if set to "left" you can produce a small message box using "small=left".
  • smallClass – the class to use for small message boxes.
  • substCheck – whether to perform a subst check or not.
  • classes – an array of classes to use with the message box.
  • imageEmptyCell – whether to use an empty <td>...</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.
  • imageEmptyCellStyle – whether empty image cells should be styled.
  • imageCheckBlank – whether "image=blank" results in no image being displayed.
  • imageSmallSize – usually, images used in small message boxes are set to 30x30px. This sets a custom size.
  • imageCellDiv – whether to enclose the image in a div enforcing a maximum image size.
  • useCollapsibleTextFields – whether to use text fields that can be collapsed, i.e. "issue", "fix", "talk", etc. Currently only used in ambox.
  • imageRightNone – whether imageright=none results in no image being displayed on the right-hand side of the message box.
  • sectionDefault – the default name for the "section" parameter. Depends on useCollapsibleTextFields.
  • allowMainspaceCategories – allow categorisation in the main namespace.
  • templateCategory – the name of a category to be placed on the template page.
  • templateCategoryRequireName – whether the name parameter is required to display the template category.
  • templateErrorCategory – the name of the error category to be used on the template page.
  • templateErrorParamsToCheck – an array of parameter names to check. If any are absent, the templateErrorCategory is applied to the template page.