Module:T-Person: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 35: | Line 35: | ||
-- Blueprint default: Initialize standard configuration | -- Blueprint default: Initialize standard configuration | ||
Blueprint.initializeConfig(template) | Blueprint.initializeConfig(template) | ||
-- CONTROL THE VISUAL ORDER THAT EACH ASPECT IS RENDERED IN | -- CONTROL THE VISUAL ORDER THAT EACH ASPECT IS RENDERED IN | ||
| Line 47: | Line 43: | ||
'logo', | 'logo', | ||
'fields', | 'fields', | ||
'achievementsSectionHeader', | |||
'achievementBadges', | 'achievementBadges', | ||
'socialMedia', | 'socialMedia', | ||
| Line 57: | Line 54: | ||
-- TEMPLATE-SPECIFIC CALLS AND CODE | -- TEMPLATE-SPECIFIC CALLS AND CODE | ||
-- BLOCK: ACHIEVEMENTS SECTION HEADER | |||
local function renderAchievementsHeader(template, args) | |||
-- Get the current page ID from the arguments pre-filled by the 'setPageIdField' preprocessor | |||
local pageId = args.ID | |||
if not pageId or pageId == '' then | |||
return '' | |||
end | |||
-- Get badge achievements using the centralized function | |||
local badgeAchievements = Achievements.getBadgeAchievements(pageId, template.current_frame) | |||
-- Only render the header if there are badges to display | |||
if #badgeAchievements > 0 then | |||
local TemplateStructure = require('Module:TemplateStructure') | |||
return TemplateStructure.renderDividerBlock("Achievements") | |||
end | |||
return '' | |||
end | |||
template.config.blocks = template.config.blocks or {} | |||
template.config.blocks.achievementsSectionHeader = { | |||
render = function(template, args) | |||
return renderAchievementsHeader(template, args) | |||
end | |||
} | |||
-- ELEMENT: ACHIEVEMENT HEADER | -- ELEMENT: ACHIEVEMENT HEADER | ||
| Line 102: | Line 125: | ||
end, | end, | ||
} | } | ||