Modul:RandomPerson: Unterschied zwischen den Versionen
Aus Sacra.Wiki
Ansichten
Aktionen
Namensräume
Varianten
Werkzeuge
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
Zeile 12: | Zeile 12: | ||
end | end | ||
frame:extensionTag('templatestyles', '', { src = 'RandomPerson/style.css' }) | local result = frame:extensionTag('templatestyles', '', { src = 'RandomPerson/style.css' }) | ||
if type( queryResult ) == "table" then | if type( queryResult ) == "table" then | ||
local | local result = '<div class="people-container">' | ||
for num, row in pairs( queryResult ) do | for num, row in pairs( queryResult ) do | ||
result = result .. '<div class="random-person">' .. row["Name"] .. '</div>\n' | |||
end | end | ||
return | return result..'</div>' | ||
end | end | ||
end | end | ||
return p | return p |
Version vom 19. Oktober 2021, 10:01 Uhr
Die Dokumentation für dieses Modul kann unter Modul:RandomPerson/Doku erstellt werden
local p = {}
function p.ask(frame)
if not mw.smw then
return "mw.smw module not found"
end
local queryResult = mw.smw.ask("[[Kategorie:Person]]|?Name|?Bildname|limit=3|order=random")
if queryResult == nil then
return "(no values)"
end
local result = frame:extensionTag('templatestyles', '', { src = 'RandomPerson/style.css' })
if type( queryResult ) == "table" then
local result = '<div class="people-container">'
for num, row in pairs( queryResult ) do
result = result .. '<div class="random-person">' .. row["Name"] .. '</div>\n'
end
return result..'</div>'
end
end
return p