(Created page with "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 title...") |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 19: | Line 19: | ||
local result = results[i] | local result = results[i] | ||
local title = mw.html.create('div'):addClass('news-title'):wikitext(mw.ext.displaytitle.get(result._pageName)) | |||
local newsItem = mw.html.create('div'):addClass('news-item'):wikitext('[[File:'. | 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) | container:node(newsItem) | ||
end | end |
Latest revision as of 06:24, 18 February 2024
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 title = mw.html.create('div'):addClass('news-title'):wikitext(mw.ext.displaytitle.get(result._pageName))
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