Module:CRTModel: Difference between revisions

No edit summary
No edit summary
Line 338: Line 338:
addSectionRow(tbl, 'Links')
addSectionRow(tbl, 'Links')
local tr = tbl:tag('tr')
-- Add links in order: Database, Manufacturer, Retailer
local td = tr:tag('td'):attr('colspan', '2')
local typeOrder = {'Database', 'Manufacturer', 'Retailer'}
css(td, 'padding:0.2em 0.4em;')
-- Create UL element
local ul = mw.html.create('ul')
ul:css('margin', '0'):css('padding-left', '1.5em')
-- Add links in order: Manufacturer, Retailer, Database
local typeOrder = {'Manufacturer', 'Retailer', 'Database'}
for _, linkType in ipairs(typeOrder) do
for _, linkType in ipairs(typeOrder) do
if #linksByType[linkType] > 0 then
if #linksByType[linkType] > 0 then
-- If multiple links of the same type, combine them in one row
local linksHtml = {}
for _, link in ipairs(linksByType[linkType]) do
for _, link in ipairs(linksByType[linkType]) do
local li = ul:tag('li')
table.insert(linksHtml, '[' .. link.url .. ' ' .. link.source .. ']')
li:wikitext('[' .. link.url .. ' ' .. link.source .. ']')
end
end
addRow(tbl, linkType, table.concat(linksHtml, '<br>'), true)
end
end
end
end
td:node(ul)
end
end


MediaWiki Appliance - Powered by TurnKey Linux