mNo edit summary |
mNo edit summary |
||
Line 26: | Line 26: | ||
local result = results[i] | local result = results[i] | ||
local img = result.image or 'News placeholder.png' | local img = result.image or 'News placeholder.png' | ||
local image = mw.html.create('div'):wikitext('[[File:' .. img .. '|300px]]') | -- local image = mw.html.create('div'):wikitext('[[File:' .. img .. '|300px]]') | ||
local title = mw.html.create('div'):addClass('companies__news__title'):wikitext(mw.ext.displaytitle.get(result._pageName)) | local title = mw.html.create('div'):addClass('companies__news__title'):wikitext(mw.ext.displaytitle.get(result._pageName)) | ||
local company = mw.html.create('div'):addClass('companies__news__item'):wikitext('[[File:'.. | local company = mw.html.create('div'):addClass('companies__news__item'):wikitext('[[File:'.. img .. '|300px|link=' .. result._pageName .. ']]'):node(title):node(mw.html.create('div'):addClass('link-overlay'):wikitext('[[File:Team_placeholder_light.png|1x1px|link=' .. result._pageName .. ']]')) | ||
companies:node(company) | companies:node(company) |
Revision as of 21:37, 23 February 2024
Documentation for this module may be created at Module:CompaniesLanding/News/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, category, game, content'
local cargoArgs = {
where = 'content LIKE "%[[Companies/%"',
orderBy = 'date DESC',
limit = args.limit or 8,
offset = args.offset
}
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
local news = mw.html.create('h3'):attr('style', 'margin-top: 0;'):wikitext('Company News')
local companies = mw.html.create('div'):addClass('companies__news')
local container = mw.html.create('div'):node(news):node(companies)
for i = 1, #results do
local result = results[i]
local img = result.image or 'News placeholder.png'
-- local image = mw.html.create('div'):wikitext('[[File:' .. img .. '|300px]]')
local title = mw.html.create('div'):addClass('companies__news__title'):wikitext(mw.ext.displaytitle.get(result._pageName))
local company = mw.html.create('div'):addClass('companies__news__item'):wikitext('[[File:'.. img .. '|300px|link=' .. result._pageName .. ']]'):node(title):node(mw.html.create('div'):addClass('link-overlay'):wikitext('[[File:Team_placeholder_light.png|1x1px|link=' .. result._pageName .. ']]'))
companies:node(company)
end
return container
end
end
return p