Module:Category more if exists: Difference between revisions
Appearance
Content deleted Content added
Make warning=yes work without a Lua error |
Add extraclasses back from Template:Cat more if exists/core |
||
Line 33: | Line 33: | ||
end |
end |
||
local mLabelledList = require('Module:Labelled list hatnote') |
local mLabelledList = require('Module:Labelled list hatnote') |
||
local options = { |
|||
⚫ | |||
extraclasses = "relarticle mainarticle" |
|||
} |
|||
⚫ | |||
return pages |
return pages |
||
end |
end |
Revision as of 16:26, 3 October 2020
![]() | This Lua module is used on approximately 42,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
Usage
Used by Template:Category more if exists
{{#invoke:Category more if exists| main}}
Note
This is a crude fork of Module:See also if exists. It may be possible to merge the two modules.
--[[ 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 mLabelledList = require('Module:Labelled list hatnote')
local options = {
extraclasses = "relarticle mainarticle"
}
local pages = mLabelledList._labelledList(rawpages, {"For more information, see", "For more information, see"}, options)
return pages
end
return p