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: Difference between revisions - 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: Difference between revisions

From CrabCraft Wiki
forgot an angle bracket
testing cargo functionality
Line 2: Line 2:


function p.buttonbox()
function p.buttonbox()
local args = {
local query = mw.ext.cargo.query(
"avatars",
"name, image, link, label",
{
{
{ "https://mc-heads.net/avatar/SirIncognito/150.png", "Main Page", "Main Page" },
limit = 100,
{ "https://mc-heads.net/avatar/AuroraFlight/150.png", "Main Page", "Main Page" }
orderBy = "name"
},
{
{ "https://mc-heads.net/avatar/Steve/150.png", "Main Page", "Main Page" },
{ "https://mc-heads.net/avatar/Morbid/150.png", "Main Page", "Main Page" }
}
}
}
)


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


for _, row in ipairs(args) do
for i, row in ipairs(query) do
table.insert(out, '|-\n')
if (i - 1) % 4 == 0 then
for _, button in ipairs(row) do
table.insert(out, '|-')
local image = button[1]
end
local link = button[2]
local label = button[3]
local cell = '| <div class="buttonbox-entry">'..image..'<div class="buttonbox-label">'..label..'</div> </div>'


table.insert(out, cell)
local image = row.image
end
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
end



Revision as of 23:01, 23 June 2025

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