Jump to content

Module:See also if exists/sandbox: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 2: Line 2:
]]
]]
local p = {}
local p = {}
local yesno = require("Module:yesno")

function doesPageExist(thisPage, ns)
local thisPage = mw.title.new( thisPage ,ns)
if thisPage == nil then
return false
end
if thisPage.exists then
return true
end
return false
end



function p.main(frame)
function p.main(frame)
Line 32: Line 21:
end
end
if (nvalid == 0) then
if (nvalid == 0) then
if yesno(frame.args.warning) then
local warning = string.format("'''%s — no output, because none of the pages currently exist.'''",frame:getParent().title)
end
return ""
return ""
end
end

Revision as of 14:34, 20 February 2019

--[[ 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
			local warning = string.format("'''%s — no output, because none of the pages currently exist.'''",frame:getParent().title)
		end
		return ""
	end
	local mLabelledList = require('Module:Labelled list hatnote')
	local pages = mLabelledList._labelledList(rawpages, "See also", "")
	return pages
end

return p