Module:See also if exists/sandbox: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
local nvalid = 0 |
local nvalid = 0 |
||
local namespace = frame.args.ns |
local namespace = frame.args.ns |
||
for i, v in ipairs( |
for i, v in ipairs(frame:getParent().args) do |
||
if (v ~= nil) then |
if (v ~= nil) then |
||
local thisArg = mw.text.trim(v) |
local thisArg = mw.text.trim(v) |
||
if (thisArg ~= "") then |
if (thisArg ~= "") then |
||
local title = mw.title.new(thisArg, |
local title = mw.title.new(thisArg, namespace) |
||
if title ~= nil and title.exists then |
if title ~= nil and title.exists then |
||
table.insert(rawpages, title.fullText) |
table.insert(rawpages, title.fullText) |
Revision as of 14:28, 20 February 2019
![]() | This is the module sandbox page for Module:See also if exists (diff). |
![]() | This Lua module is used on approximately 74,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. |
![]() | This module depends on the following other modules: |
Usage
Used by Template:see also if exists and Template:Category see also if exists.
{{#invoke:See also if exists| main}}
--[[ v1.0
]]
local p = {}
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)
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
return ""
end
local mLabelledList = require('Module:Labelled list hatnote')
local pages = mLabelledList._labelledList(rawpages, "See also", "")
return pages
end
return p