Documentation for this module may be created at Module:PageTabs team/doc
local cargo = mw.ext.cargo
local p = {}
function p.main(frame)
local currentTitle = mw.title.getCurrentTitle().text
local split = mw.text.split(currentTitle, '/')
local parent = split[1] .. '/' .. split[2]
local subPage = split[3]
local str = '{{Tabs|name1=Overview|link1=' .. parent
local order = 1
if subPage == 'Results' then
order = order + 1
str = str .. '|name' .. order .. '=Results' .. '|link' .. order .. '=' .. currentTitle
else
-- Check if has results
local tables = "AllMatches"
local fields = '_pageName'
local cargoArgs = {
where = '(p1 = "' .. parent .. '" OR p2="' .. parent .. '") AND winner IS NOT NULL AND winner != "0"',
limit = 1,
}
local soloMatches = cargo.query(tables, fields, cargoArgs)
local hadResults = false
if #soloMatches > 0 then
hadResults = true
else
-- Check if part of tournament prizes
tables = 'Participants, Prizes'
fields = 'Participants._pageName=_pageName'
cargoArgs = {
join = 'Participants._pageName=Prizes._pageName',
where = 'Participants.team = "' .. parent .. '"',
limit = 1
}
local placementResults = cargo.query(tables, fields, cargoArgs)
if #placementResults > 0 then
hadResults = true
end
end
if hadResults then
order = order + 1
str = str .. '|name' .. order .. '=Results' .. '|link' .. order .. '=' .. parent .. '/Results'
end
end
str = str .. '}}'
if order > 1 then return frame:preprocess(str) end
end
return p