Deprecated: Use of MediaWiki\Parser\Parser::$extTemplateStylesCache was deprecated in MediaWiki 1.42. [Called from MediaWiki\Extension\TemplateStyles\Hooks::onParserFirstCallInit in /var/www/html/extensions/TemplateStyles/includes/Hooks.php at line 216] in /var/www/html/includes/debug/MWDebug.php on line 372
Module:ButtonBox - CrabCraft Wiki Jump to content

📢 Please make sure to read our Style Guide before editing. For questions, suggestions, or technical issues, please contact Noah.

Module:ButtonBox

From CrabCraft Wiki
Revision as of 23:01, 23 June 2025 by Noah (talk | contribs) (testing cargo functionality)

Documentation for this module may be created at Module:ButtonBox/doc

local p = {}

function p.buttonbox()
	local query = mw.ext.cargo.query(
		"avatars",
		"name, image, link, label",
		{
			limit = 100,
			orderBy = "name"
		}
	)

	local out = {}
	table.insert(out, '{| class="buttonbox"')
	
	local out = {}
	table.insert(out, '{| class="buttonbox"')

	for i, row in ipairs(query) do
		if (i - 1) % 4 == 0 then
			table.insert(out, '|-')
		end

		local image = row.image
		local label = row.label or row.name
		local link = row.link or ("[[User:" .. row.name .. "]]")

		local cell = '| <div class="buttonbox-entry">'..image..'<div class="buttonbox-label">'..label..'</div> </div>'

		table.insert(out, cell)
	end

	table.insert(out, '|}')
	return table.concat(out, '\n')
end

return p