Module:CategoryList: Difference between revisions
From MEpedia, a crowd-sourced encyclopedia of ME and CFS science and history
(Support multiple categories) |
(restrict loop to numeric arguments) |
||
Line 12: | Line 12: | ||
local categoryList = '' | local categoryList = '' | ||
for k, category in pairs( frame.args ) do | for k, category in pairs( frame.args ) do | ||
categoryList = categoryList .. [[category = ]] .. category .. '\n ' | if string.match(k, '[0-9]') then categoryList = categoryList .. [[category = ]] .. category .. '\n ' end | ||
end | end | ||
Line 41: | Line 41: | ||
local categoryList = '' | local categoryList = '' | ||
for k, category in pairs( | for k, category in pairs( frame.args ) do | ||
categoryList = categoryList .. [[category = ]] .. category .. '\n ' | if string.match(k, '[0-9]') then categoryList = categoryList .. [[category = ]] .. category .. '\n ' end | ||
end | end | ||
Revision as of 15:13, May 3, 2018
Documentation for this module may be created at Module:CategoryList/doc
--See Module:CategoryListOld for more complete, but failed attempt
local p = {}
function p.pagesInCategory (frame)
local categories = frame.args
local listStyleType = frame.args.mode
if listStyleType == nil or listStyleType == '' then listStyleType = 'inline-bullets' end
local columnCount = frame.args.columnCount or ''
if columnCount then columnCount = 'columncount = ' .. columnCount end
local categoryList = ''
for k, category in pairs( frame.args ) do
if string.match(k, '[0-9]') then categoryList = categoryList .. [[category = ]] .. category .. '\n ' end
end
local opts = [[
]] .. categoryList .. [[
shownamespace = true
mode = ]] .. listStyleType .. [[
ordermethod = sortkey
order = ascending
]] .. columnCount .. [[
]]
return frame:extensionTag('DynamicPageList', opts)
end
function p.categoriesInCategory (frame)
local categories = frame.args
local listStyleType = frame.args.mode
if listStyleType == nil or listStyleType == '' then listStyleType = 'inline-bullets' end
local columnCount = frame.args.columnCount or ''
if columnCount then columnCount = 'columncount = ' .. columnCount end
local categoryList = ''
for k, category in pairs( frame.args ) do
if string.match(k, '[0-9]') then categoryList = categoryList .. [[category = ]] .. category .. '\n ' end
end
local opts = [[
]] .. categoryList .. [[
namespace = Category
shownamespace = false
mode = ]] .. listStyleType .. [[
ordermethod = sortkey
order = ascending
]] .. columnCount .. [[
]]
return frame:extensionTag('DynamicPageList', opts)
end
function p.main (frame)
return p.pagesInCategory(frame)
end
return p