Documentation for this module may be created at Module:NewsLanding/Slider/doc
local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local p = {}
function p.main(frame)
local tables = 'News'
local fields = '_pageName, date, image'
local cargoArgs = {
orderBy = 'date DESC',
limit = 5,
}
local results = cargo.query(tables, fields, cargoArgs)
local container = mw.html.create('div'):attr('id', 'news-slider-container')
if #results > 0 then
for i = 1, #results do
local result = results[i]
local image = result.image or 'News placeholder.png'
local newsItem = mw.html.create('div'):addClass('news-item'):wikitext('[[File:'.. image .. '|link=' .. result._pageName .. ']]'):node(title)
container:node(newsItem)
end
return container
end
end
return p