Module:BrandSeries: Difference between revisions
Fix: preprocess final wikitext output to render links and table (via update-page on MediaWiki MCP Server) |
Rewrite using HTML builder like CRTModel; fix count parsing (via update-page on MediaWiki MCP Server) |
||
| Line 31: | Line 31: | ||
if not seriesResult or seriesResult == '' then | if not seriesResult or seriesResult == '' then | ||
return " | return "<i>No series found.</i>" | ||
end | end | ||
| Line 57: | Line 57: | ||
if count > 0 then | if count > 0 then | ||
-- Build browse link and preprocess it | |||
local browseLink = string.format( | |||
'{{#queryformlink:form=CRT query|query string=CRT query[brand]=%s&CRT query[series]=%s&_run|link text=Browse}}', | |||
brand, series | |||
) | |||
local browseHtml = frame:preprocess(browseLink) | |||
table.insert(rows, { | table.insert(rows, { | ||
series = series, | series = series, | ||
count = count | count = count, | ||
browse = browseHtml | |||
}) | }) | ||
end | end | ||
| Line 66: | Line 74: | ||
-- If no series found for this brand | -- If no series found for this brand | ||
if #rows == 0 then | if #rows == 0 then | ||
return " | return "<i>No series-assigned models for this brand.</i>" | ||
end | end | ||
-- Build the table as | -- Build the table as HTML | ||
local | local tbl = mw.html.create('table') | ||
tbl:addClass('wikitable') | |||
-- Header row | |||
local headerRow = tbl:tag('tr') | |||
headerRow:tag('th'):wikitext('Series') | |||
headerRow:tag('th'):wikitext('Count') | |||
headerRow:tag('th'):wikitext('Browse') | |||
-- Data rows | |||
for _, row in ipairs(rows) do | for _, row in ipairs(rows) do | ||
local tr = tbl:tag('tr') | |||
tr:tag('td'):wikitext('[[' .. row.series .. ']]') | |||
tr:tag('td'):wikitext(tostring(row.count)) | |||
tr:tag('td'):wikitext(row.browse) | |||
end | end | ||
return tostring(tbl) | |||
return | |||
end | end | ||
return p | return p | ||