มอดูล:Sandbox/Nullzero/multicoldpl

จาก วิกิตำรา

เอกสารการใช้งานสำหรับมอดูลนี้อาจสร้างขึ้นที่ มอดูล:Sandbox/Nullzero/multicoldpl/doc

local p = {}

function p.gen(frame)
    local category = frame.args.category or frame.args[1]
    local column = tonumber(frame.args.column or frame.args[2] or 3)
    local each = tostring(math.ceil(tonumber(frame:preprocess("{{PAGESINCATEGORY:" .. category .. "}}")) / column))
    local t = {"<table><tr>"}
    for i = 1, column do
        table.insert(t, "<td style='vertical-align:top;'><dynamicpagelist>\ncategory = "  .. category .. 
                                                "\ncount = " .. each .. 
                                                "\noffset = " .. tostring((i - 1) * each) ..
                                                "\nordermethod = sortkey" ..
                                                "\norder = ascending" ..
                        "</dynamicpagelist>" .. "</td>")
    end
    table.insert(t, "</tr></table>")
    return frame:preprocess(table.concat(t))
end

return p