Module:T-Campaign: Difference between revisions
// via Wikitext Extension for VSCode Tag: Reverted |
// via Wikitext Extension for VSCode |
||
| (15 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- T-Campaign.lua | -- Module:T-Campaign.lua | ||
-- Generic campaign template that dynamically loads campaign data from JSON files | -- Generic campaign template that dynamically loads campaign data from JSON files | ||
-- Usage: {{#invoke:T-Campaign|render|campaign_name= | -- Usage: {{#invoke:T-Campaign|render|campaign_name=NAME}} | ||
local p = {} | local p = {} | ||
| Line 172: | Line 172: | ||
local banner = args._campaign_data.banner | local banner = args._campaign_data.banner | ||
local bannerContent = banner.content or "" | local bannerContent = banner.content or "" | ||
local titleText = template.config.constants.title or "Campaign" | |||
-- Combine generic notice-box class with specific campaign class | -- Combine generic notice-box class with specific campaign class | ||
local cssClass = "notice-box" | local cssClass = "notice-box" | ||
| Line 183: | Line 185: | ||
end | end | ||
-- | -- Use the centralized NoticeFactory to create the notice | ||
local noticeOptions = { | |||
type = "campaign-js", | |||
local | |||
type = "campaign", | |||
position = "top", | position = "top", | ||
content = bannerContent, | content = bannerContent, | ||
title = titleText, | |||
cssClass = cssClass | cssClass = cssClass | ||
} | } | ||
return WikitextProcessor.createNoticeForJS(noticeOptions) .. ErrorHandling.formatCombinedOutput(context) | |||
end | end | ||
} | } | ||
| Line 410: | Line 369: | ||
-- Always show campaign content fields (they'll show placeholder text when empty) | -- Always show campaign content fields (they'll show placeholder text when empty) | ||
for _, fieldDef in ipairs(campaignData.field_definitions) do | for _, fieldDef in ipairs(campaignData.field_definitions) do | ||
table.insert(fields, { | -- CRITICAL: Skip 'title' as it is not a content field | ||
if fieldDef.key ~= "title" then | |||
table.insert(fields, { | |||
key = fieldDef.key, | |||
label = fieldDef.label, | |||
type = fieldDef.type | |||
}) | |||
end | |||
end | end | ||
| Line 434: | Line 396: | ||
end | end | ||
-- Add campaign-specific category | -- Add campaign-specific category, defaulting to template_id | ||
template.config.categories.base = { | local category_value = campaignData.category or campaignData.template_id | ||
template.config.categories.base = {category_value} | |||
return args | return args | ||