Documentation for this module may be created at Module:NewsLanding/Featured/doc
local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local p = {}
function p.main(frame)
local args = getArgs(frame)
local tables = 'News'
local fields = '_pageName, date, image'
local cargoArgs = {
orderBy = 'date DESC',
where = '_pageName = "News/' .. string.gsub(args.first, '"', '""') .. '"'
}
local results = cargo.query(tables, fields, cargoArgs)
local newsItemContainer = mw.html.create('div'):addClass('news-featured-items')
local container = mw.html.create('div'):addClass('news-featured-container'):node(mw.html.create('h3'):wikitext('Featured')):node(newsItemContainer)
if #results > 0 then
local result = results[1]
local title = mw.html.create('div'):wikitext(mw.ext.displaytitle.get(result._pageName))
local newsItem = mw.html.create('div'):addClass('news-featured'):wikitext('[[File:'.. result.image .. '|link=' .. result._pageName .. ']]'):node(title)
newsItemContainer:node(newsItem)
end
cargoArgs.where = '_pageName = "News/' .. string.gsub(args.second, '"', '""') .. '"'
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
local result = results[1]
local title = mw.html.create('div'):wikitext(mw.ext.displaytitle.get(result._pageName))
local newsItem = mw.html.create('div'):addClass('news-featured'):wikitext('[[File:'.. result.image .. '|link=' .. result._pageName .. ']]'):node(title)
newsItemContainer:node(newsItem)
end
return container
end
return p