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:SongCategories

From King Warz Charts

This module is used by the {{Infobox song}} template to assign categories based on the |type= parameter. It processes the song type and adds appropriate categories to articles.

Usage

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

{{#invoke:SongCategories|getCategories|type={{{type|}}}}}

The module expects a type parameter with one of the following values:

  • Top 10 Hit Song: Adds [[Category:Top 10 Hit songs]].
  • No.1 Hit Song: Adds [[Category:Number One Songs]].
  • Major Hit Song: Adds [[Category:Major Hit Songs]] and [[Category:Number One Songs]].
  • Any other value or empty input: No categories are added.

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
| rating = 4
}}

This will add the article to [[Category:Major Hit Songs]] and [[Category:Number One Songs]].

Notes

  • The module is case-sensitive. Ensure the type parameter matches the exact values (Top 10 Hit Song, No.1 Hit Song, Major Hit Song).
  • If you need case-insensitive matching, the module can be modified to normalize the input (e.g., convert to lowercase).
  • Ensure the categories ([[Category:Top 10 Hit songs]], [[Category:Number One Songs]], [[Category:Major Hit Songs]]) exist on the wiki to avoid redlinks.

See also


local p = {}

function p.getCategories(frame)
    local songType = frame.args['type'] or ''
    local categories = {}

    if songType == 'Top 10 Hit Song' then
        table.insert(categories, '[[Category:Top 10 Hit Songs]]')
    elseif songType == 'No.1 Hit Song' then
        table.insert(categories, '[[Category:Number One Songs]]')
    elseif songType == 'Major Hit Song' then
        table.insert(categories, '[[Category:Major hit songs]]')
        table.insert(categories, '[[Category:Number One Songs]]')
    end

    return table.concat(categories, '')
end

return p