Module:Songs: Difference between revisions

Jump to navigation Jump to search
110 bytes added ,  Thursday at 01:30
no edit summary
mNo edit summary
No edit summary
Line 61: Line 61:
orderBy = "Album_Songs.song_page ASC, Album_Songs.album ASC"
orderBy = "Album_Songs.song_page ASC, Album_Songs.album ASC"
}
}
local fields = { 'song_page', 'album', 'type', 'singers' }
local fields = { 'song_page', 'song_title', 'album', 'type', 'singers' }
local results = cargo.query('Album_Songs', table.concat(fields, ','), query)
local results = cargo.query('Album_Songs', table.concat(fields, ','), query)


local groups = {}
local groups = {}
local pageNames = {}
for _, result in ipairs(results) do
for _, result in ipairs(results) do
local singers = mw.text.split(result.singers, ",")
local singers = mw.text.split(result.singers, ",")
Line 82: Line 83:


if type ~= nil then
if type ~= nil then
if not groups[result.song_page] then groups[result.song_page] = {} end
if not groups[result.song_title] then groups[result.song_title] = {} end
table.insert(groups[result.song_page], { album = result.album, type = type })
pageNames[result.song_title] = result.song_page
table.insert(groups[result.song_title], { album = result.album, type = type })
end
end
end
end
Line 92: Line 94:
local head = table.remove(rows, 1)
local head = table.remove(rows, 1)
text = text ..
text = text ..
string.format('|-\n| rowspan=%d|[[%s]] || [[%s]] || %s\n', rowspan, song, head.album, head.type)
string.format('|-\n| rowspan=%d|[[%s|%s]] || [[%s]] || %s\n', rowspan, song, pageNames[song], head.album, head.type)
for _, row in ipairs(rows) do
for _, row in ipairs(rows) do
text = text ..
text = text ..

Navigation menu