Module:RecursiveSelectiveList: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
Line 31: | Line 9: | ||
end | end | ||
-- Fetch category | -- Fetch the category | ||
local | local category = mw.title.new("Category:" .. categoryName) | ||
if not | if not category then | ||
return "Error: " | return "Error: Invalid category name." | ||
end | end | ||
-- Get category members | |||
local members = category:linkedPages() | |||
local output = {} | |||
for _, member in ipairs(members) do | |||
table.insert(output, "* [[" .. member.fullText .. "]]") | |||
end | end | ||
if #output == 0 then | |||
return "No pages found in the category." | |||
end | end | ||
Revision as of 06:49, 22 December 2024
Documentation for this module may be created at Module:RecursiveSelectiveList/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local categoryName = args['categoryName']
if not categoryName then
return "Error: Please provide a category name."
end
-- Fetch the category
local category = mw.title.new("Category:" .. categoryName)
if not category then
return "Error: Invalid category name."
end
-- Get category members
local members = category:linkedPages()
local output = {}
for _, member in ipairs(members) do
table.insert(output, "* [[" .. member.fullText .. "]]")
end
if #output == 0 then
return "No pages found in the category."
end
return table.concat(output, "\n")
end
return p