Module:Message box

From Chalo Chatu, Zambia online encyclopedia
Revision as of 11:12, 22 July 2025 by Chalochatu (talk | contribs)
Jump to navigationJump to search

-- Module:Message box/doc -- This is the documentation page for Module:Message box. -- Editors: Please do not edit the module itself here. Documentation only.

Module:Message box

This module creates standardized message boxes such as {{ambox}}, {{imbox}}, {{ombox}}, etc. It is a Lua implementation of the various "box" templates and should be used via those templates, not directly.

Usage

You normally do not call this module directly. Instead, use one of the wrapper templates:

  • {{ambox}} – for article message boxes
  • {{imbox}} – for file and image pages
  • {{tmbox}} – for talk page message boxes
  • {{ombox}} – for other namespaces
  • {{cmbox}} – for category pages

Each wrapper template passes parameters to this module to generate a consistent, styled message box.

Parameters

The wrapper templates accept the following parameters:

type
The type of message box. Examples: speedy, delete, content, style, notice, protection.
This controls the color and icon.
image
Optional custom image/icon (overrides default).
text
The main message text shown in the box.
small
If set to "yes", produces a smaller version of the box.
style
Additional CSS styling applied to the box.
class
Adds custom classes to the message box.

Example

{{ambox | type = content | text = This article needs additional references for verification. }}

Produces:

Script error: The function "ambox" does not exist.

See also


local p = {}

-- Disable TemplateStyles temporarily
local function loadTemplateStyles()
	-- Normally loads Module:Message box/ombox.css
	-- But disabled because TemplateStyles is not installed
	return '' -- Return nothing to avoid raw tags
end

-- This function is called directly by some modules
function p.ombox(frame)
	local args = frame:getParent().args
	local boxType = args.type or 'notice'
	local boxClass = 'mbox mbox-' .. boxType
	local boxStyle = args.style or ''
	local text = args.text or ''
	
	local box = mw.html.create('table')
	box:addClass(boxClass)
	box:cssText(boxStyle)
	
	local tr = box:tag('tr')
	tr:tag('td'):addClass('mbox-text'):wikitext(text)
	
	return loadTemplateStyles() .. tostring(box)
end

-- This is the "main" function that Module:High-use expects
function p.main(_type, data)
	local boxType = data.type or 'notice'
	local boxClass = 'mbox mbox-' .. boxType
	local boxStyle = data.style or ''
	local text = data.text or ''
	
	local box = mw.html.create('table')
	box:addClass(boxClass)
	box:cssText(boxStyle)
	
	local tr = box:tag('tr')
	tr:tag('td'):addClass('mbox-text'):wikitext(text)
	
	return loadTemplateStyles() .. tostring(box)
end

return p