Module:CategoryListOld

From MEpedia, a crowd-sourced encyclopedia of ME and CFS science and history

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

local p = {}

function p.getPageList (category, frame)

	local opts = [[

		category = ]] .. category .. [[

		shownamespace = true
		mode = inline-bullets
		ordermethod = sortkey
		order     = ascending
	]]

	return frame:extensionTag('DynamicPageList', opts)
end

-- We need this hack until categories accessible: https://phabricator.wikimedia.org/T50175
function p.getCategoryList (category, frame)
	local opts = [[

		category = ]] .. category .. [[

		namespace = Category
		shownamespace = false
		mode = inline-bullets
		ordermethod = sortkey
		order     = ascending
		raw       = true
	]]
	local tag = frame:extensionTag('DynamicPageList', opts)
	-- return #(mw.text.split(tag, 'e1d')) -- not working for some reason unless empty string
	-- local s = tostring(frame:preprocess(tag))
	-- return table.concat(mw.text.split(frame:newParserValue(tag).expand(), 'a'), '==') -- doesn't work!!!
	-- return mw.text.split(frame:newParserValue(tag).expand(), 'a').text
	return frame:newParserValue(table.concat(mw.text.split(mw.clone(tag), 'a'), '==')).expand()
	-- return frame:newParserValue(tag).expand()
	--local catTable = {}
	--for cat in mw.ustring.match(tag, 'an') do
    --	table.insert(catTable, cat)
	--end
	--return #catTable
end

function p.main (frame)
	local category = frame.args[1]
	local depth = frame.args[2] or 3
	local catList = p.getCategoryList(category, frame)
	return catList
	-- return table.concat(catList, '==') -- .. p.getPageList('Body systems', frame)
	-- return (table.concat(catList, '=='))
end
 
return p