No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
local currentTitle = mw.title.getCurrentTitle().text | local currentTitle = mw.title.getCurrentTitle().text | ||
-- Look up Cargo table teams with current page as sponsor | -- Look up Cargo table teams with current page as sponsor | ||
local tables = 'Teams' | local tables = 'Sponsors, Teams' | ||
local fields = '_pageName' | local fields = 'Sponsors._pageName' | ||
local cargoArgs = { | local cargoArgs = { | ||
where = ' | join = 'Sponsors._pageName=Teams._pageName, Sponsors._pageName=Teams.org', | ||
where = 'Sponsors.id= "' ..currentTitle .. '" OR Teams.org="' .. currentTitle .. '"', | |||
limit=10, | |||
orderBy='Sponsors.start' | |||
} | } | ||
local results = cargo.query(tables, fields, cargoArgs) | local results = cargo.query(tables, fields, cargoArgs) | ||
local ul = mw.html.create('ul') | if #results > 0 then | ||
local ul = mw.html.create('ul') | |||
for r = 1, #results do | |||
mw.log(results[r]) | |||
mw.logObject(results[r]) | |||
local result = results[r] | |||
local li = mw.html.create('li') | |||
:wikitext('[[' .. result._pageName .. ']]') | |||
ul:node(li) | |||
end | |||
else | |||
return nil | |||
end | |||
return container:node(ul) | return container:node(ul) |
Revision as of 13:12, 22 September 2022
Documentation for this module may be created at Module:Sponsored teams/doc
local cargo = mw.ext.cargo
local Sponsored = {}
function Sponsored.get(frame)
local container = mw.html.create('div')
:addClass('sponsored')
local currentTitle = mw.title.getCurrentTitle().text
-- Look up Cargo table teams with current page as sponsor
local tables = 'Sponsors, Teams'
local fields = 'Sponsors._pageName'
local cargoArgs = {
join = 'Sponsors._pageName=Teams._pageName, Sponsors._pageName=Teams.org',
where = 'Sponsors.id= "' ..currentTitle .. '" OR Teams.org="' .. currentTitle .. '"',
limit=10,
orderBy='Sponsors.start'
}
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
local ul = mw.html.create('ul')
for r = 1, #results do
mw.log(results[r])
mw.logObject(results[r])
local result = results[r]
local li = mw.html.create('li')
:wikitext('[[' .. result._pageName .. ']]')
ul:node(li)
end
else
return nil
end
return container:node(ul)
end
return Sponsored