Module:CheckCategory
Appearance
[create] Documentation
-- Module:CategoryCheck
local p = {}
local function isPageInCategory(page, category)
local title = mw.title.new(page)
if not title then
return false
end
local categories = mw.site.categoriesInPage(title)
for _, cat in ipairs(categories) do
if cat == category then
return true
end
end
return false
end
function p.isInCategory(frame)
local page = frame.args.page or mw.title.getCurrentTitle().text
local category = frame.args.category
if not category then
return "Error: No category specified."
end
local inCategory = isPageInCategory(page, category)
if inCategory then
return "Page '" .. page .. "' is in category '" .. category .. "'."
else
return "Page '" .. page .. "' is NOT in category '" .. category .. "'."
end
end
return p