Module:RecursiveSelectiveList: Difference between revisions

From Ikwipedia
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
--[[local p = {}
local mw = require('mw')
local mw = require('mw')


Line 6: Line 6:
     local content = mw.title.new(categoryName):getContent()
     local content = mw.title.new(categoryName):getContent()
     return content or "The category '" .. categoryName .. "' does not exist or has no content."
     return content or "The category '" .. categoryName .. "' does not exist or has no content."
end
return p]]--
local p = {}
function p.getCategoryMembers(frame)
    local categoryName = frame.args[1] -- Pass the category name as an argument
    local category = mw.title.new("Category:" .. categoryName)
    if not category or not category.exists then
        return "Category does not exist."
    end
    local members = category:members()
    local result = {}
    for page in members do
        table.insert(result, page.title) -- Collect page titles
    end
    return table.concat(result, ", ") -- Return a comma-separated list of page titles
end
end


return p
return p

Revision as of 08:18, 22 December 2024

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

--[[local p = {}
local mw = require('mw')

function p.main(frame)
    local categoryName = "Category:" .. frame.args.categoryName
    local content = mw.title.new(categoryName):getContent()
    return content or "The category '" .. categoryName .. "' does not exist or has no content."
end

return p]]--

local p = {}

function p.getCategoryMembers(frame)
    local categoryName = frame.args[1] -- Pass the category name as an argument
    local category = mw.title.new("Category:" .. categoryName)

    if not category or not category.exists then
        return "Category does not exist."
    end

    local members = category:members()
    local result = {}

    for page in members do
        table.insert(result, page.title) -- Collect page titles
    end

    return table.concat(result, ", ") -- Return a comma-separated list of page titles
end

return p