Jump to content

Welcome to King Warz Charts Wiki! Please note that the site is still under construction as I work on creating past chart week pages, as well as templates and pages for artists, songs, and albums. Because of this, you may see a lot of red links throughout the site.

Module:SongCertifications

From King Warz Charts

This module is used by the {{Infobox song}} template to format the |certification= parameter and assign categories based on the certification level of a song.

Usage

The module is invoked within the {{Infobox song}} template as follows:

{{#invoke:SongCertifications|getCertification|certification={{{certification|}}}}}

The module processes the |certification= parameter and formats the output while adding appropriate categories:

  • Gold (case-insensitive): Displays Gold and adds [[Category:Gold Songs]].
  • A number from 1 to 9: Displays Nx Platinum (e.g., 3x Platinum for 3) and adds [[Category:Platinum Songs]].
  • A number 10 or higher: Displays Nx Diamond (e.g., 24x Diamond for 24) and adds [[Category:Diamond Songs]].
  • Invalid inputs (e.g., non-numeric values other than Gold, or numbers less than 1): Displays the input as-is and adds [[Category:Songs with Invalid Certifications]].

Example

In an article using the {{Infobox song}} template:

{{Infobox song
| name = Example Song
| type = Major Hit Song
| artist = Example Artist
| album = Example Album
| released = January 1, 2020
| genre = Pop
| certification = 24
| rating = 4
}}

This will display the certification as 24x Diamond and add the article to [[Category:Diamond Songs]].

Notes

  • The module is case-insensitive for Gold (e.g., gold, GOLD are accepted).
  • Invalid inputs, such as 23x Diamond or non-numeric values other than Gold, are displayed as entered and categorized in [[Category:Songs with Invalid Certifications]] for manual review.
  • Ensure the categories ([[Category:Gold Songs]], [[Category:Platinum Songs]], [[Category:Diamond Songs]], [[Category:Songs with Invalid Certifications]]) exist on the wiki to avoid redlinks.

See also


local p = {}

function p.getCertification(frame)
    local certInput = mw.text.trim(frame.args['certification'] or '')
    local output = ''
    local categories = {}

    -- Check for "Gold" (case-insensitive)
    if certInput:lower() == 'gold' then
        output = '[[Gold]] ●'
        table.insert(categories, '[[Category:Gold Songs]]')
    -- Check if input is a number
    elseif certInput:match('^%d+$') then
        local num = tonumber(certInput)
        if num >= 1 and num <= 9 then
            output = num .. 'x [[Platinum]] ▲'
            table.insert(categories, '[[Category:Platinum Songs]]')
        elseif num >= 10 then
            output = num .. 'x [[Diamond]] ⬥'
            table.insert(categories, '[[Category:Diamond Songs]]')
        else
            -- Invalid number (e.g., 0 or negative)
            output = certInput
            table.insert(categories, '[[Category:Songs with Invalid Certifications]]')
        end
    else
        -- Invalid input (not "Gold" or a number)
        output = certInput
        table.insert(categories, '[[Category:Songs with Invalid Certifications]]')
    end

    return output .. table.concat(categories, '')
end

return p