Jump to content

Module:Category more if exists: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Add extraclasses back from Template:Cat more if exists/core
Fix stray colon; this is not a "labelled list hatnote" as that module defines it, so shouldn't use that module
Line 32: Line 32:
return ""
return ""
end
end
local mLabelledList = require('Module:Labelled list hatnote')
local mHatnote = require("Module:Hatnote")
local mHatList = require("Module:Hatnote list")
local options = {
local options = {
extraclasses = "relarticle mainarticle"
extraclasses = "relarticle mainarticle"
}
}
local pages = mLabelledList._labelledList(rawpages, {"For more information, see", "For more information, see"}, options)
local hatnoteText = string.format("For more information, see %s", mHatList.andList(rawpages, true))
return mHatnote._hatnote(hatnoteText, options)
return pages
end
end



Revision as of 00:30, 4 October 2020

--[[ v1.0
]]
local p = {}
local yesno = require("Module:yesno")

function p.main(frame)
	local rawpages = {}
	local nvalid = 0
	local namespace = frame.args.ns
	for i, v in ipairs(frame:getParent().args) do
		if (v ~= nil) then
			local thisArg = mw.text.trim(v)
			if (thisArg ~= "") then
				local title = mw.title.new(thisArg, namespace)
				if title ~= nil and title.exists then
					table.insert(rawpages, title.fullText)
					nvalid = nvalid + 1
				end
			end
		end
	end
	if (nvalid == 0) then
		if yesno(frame.args.warning) then
			if namespace == nil then
				namespace = "page"
			elseif namespace:sub(-1) == "y" then
				namespace = namespace:sub(0, -2) .. "ie"
			end
			mw.addWarning(string.format("'''[[%s]] — no output, because none of the %ss currently exist.'''",
				frame:getParent():getTitle(),namespace))
		end
		return ""
	end
	local mHatnote = require("Module:Hatnote")
	local mHatList = require("Module:Hatnote list")
	local options = {
		extraclasses = "relarticle mainarticle"
	}
	local hatnoteText = string.format("For more information, see %s", mHatList.andList(rawpages, true))
	return mHatnote._hatnote(hatnoteText, options)
end

return p