Lisää toimintoja
Ak: Uusi sivu: local p = {} function p.listPagesInCategory(frame) -- Name of the category to list pages from local categoryName = frame.args.category or "ExampleCategory" -- Ensure the category starts with "Category:" if not categoryName:match("^Category:") then categoryName = "Category:" .. categoryName end -- Get the category object local category = mw.title.new(categoryName) if not category or not category.exists then return "The cat... |
(ei mitään eroa)
|
Versio 12. joulukuuta 2024 kello 00.46
Tämän moduulin ohjeistuksen voi tehdä sivulle Moduuli:ListCategoryPages/ohje
local p = {}
function p.listPagesInCategory(frame)
-- Name of the category to list pages from
local categoryName = frame.args.category or "ExampleCategory"
-- Ensure the category starts with "Category:"
if not categoryName:match("^Category:") then
categoryName = "Category:" .. categoryName
end
-- Get the category object
local category = mw.title.new(categoryName)
if not category or not category.exists then
return "The category does not exist."
end
-- Fetch all pages in the category
local pages = category:categoryMembers()
local result = {}
for pageTitle, _ in pairs(pages) do
table.insert(result, pageTitle)
end
-- Sort the result alphabetically
table.sort(result)
-- Format the output as a bulleted list
local output = ""
for _, title in ipairs(result) do
output = output .. "* [[" .. title .. "]]\n"
end
return output
end
return p