Module:GetCategories

From Abiotic Factor Wiki
Jump to navigation Jump to search

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

local p = {}
local cargo = mw.ext.cargo

--[[
{{#cargo_query:
tables=Items
|format=ul
|fields=_pageName
|where=category is null
|order by=name
}}]]

function p.Main( frame )
    local tables = 'Items'
    local fields = 'name'
    -- optional parameters are grouped in one table
    -- you can omit any or all of them, except join if you use more than one table
    local args = {
        where = 'category is null',
        orderBy = 'name'
    }
    local results = cargo.query( tables, fields, args )
    return results
end

function p.dev_nocat ()
	results = p.Main()
	local output = ""
        for k, v in ipairs(results) do 
        	if string.find(mw.title.new(v["name"]):getContent(), "{{dev}}", 1, true) then
        		output = output .. "<li>[[" .. v["name"] .. "]]</li>"
        	else
        		output = output .. '<li style="list-style:square;background-color:black">[[' .. v["name"] .. ']]</li>'
        	end
       	end
    return output
end

return p