Modul:ListeBasistyp: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Stewie (Diskussion | Beiträge) |
Stewie (Diskussion | Beiträge) |
||
Zeile 25: | Zeile 25: | ||
then | then | ||
returnString = returnString .. '<tr>' -- neue tabellen reihe | returnString = returnString .. '<tr>' -- neue tabellen reihe | ||
− | returnString = returnString ..'<td>[[' .. queryResult[i][1] .. ']](' .. basistypArtikelinfo[1]['Artikelinfo'] ..')</td>' | + | returnString = returnString ..'<td>[[' .. queryResult[i][1] .. ']] (' .. basistypArtikelinfo[1]['Artikelinfo'] ..')</td>' |
end | end | ||
if basistypArtikelinfo[1]['Profilbild'] ~= nil | if basistypArtikelinfo[1]['Profilbild'] ~= nil |
Version vom 22. November 2020, 16:44 Uhr
Die Dokumentation für dieses Modul kann unter Modul:ListeBasistyp/Doku erstellt werden
--[[
Lua Alternative für Vorlage:Liste Basistyp (in der Hoffnung auf bessere Performance)
erwartet ein basistyp als argument und stellt zugehörigen Seiten da.
]]--
local p = {} --local p = {} -- p steht für Paket (engl. package)
function p.Liste( frame )
local returnString = ""
local Basistyp = frame.args['Basistyp']
-- test ob Basistyp leer ist wenn ja, beende hier
if Basistyp == nil then return nil end
-- Todo: test ob argument tatsächlich ein basistyp ist wenn nicht beende hier
-- Semantische Abfrage nach Seiten mit diesen Basistyp
local queryResult = mw.smw.ask('[[Basistyp::'..Basistyp .. ']]|?=#|limit=1999') --link=none funktioniert nicht über api abfrage daher ?=#
-- tabellen kopf
returnString = '<table class="wikitable sortable oben" ><tr><th>' .. Basistyp ..'</th><th>Gehört zu...</th><th>Quellen</th></tr>'
-- loop über query result und erstelle tabelle
local i = 1
while i <= table.getn(queryResult)
do
local basistypArtikelinfo = mw.smw.ask('[[' .. queryResult[i][1] ..']]|?Artikelinfo|?Profilbild|?GehörtZu|?Publikation|mainlabel=-')
-- um fehler zu vermeiden auf nil prüfen
if basistypArtikelinfo[1]['Artikelinfo'] ~= nil
then
returnString = returnString .. '<tr>' -- neue tabellen reihe
returnString = returnString ..'<td>[[' .. queryResult[i][1] .. ']] (' .. basistypArtikelinfo[1]['Artikelinfo'] ..')</td>'
end
if basistypArtikelinfo[1]['Profilbild'] ~= nil
then
-- Vorlage:Vorschaubild.Kreis ggf. als eigene Funktion auslagern wenn öfter notwendig
returnString = returnString .. '<td><div style="width: 64px; height: 64px; border-radius: 64px; -webkit-border-radius: 640px; -moz-border-radius: 64px; overflow:hidden; float:right; background:lightgray; ">'
returnString = returnString ..'[[Datei:'..basistypArtikelinfo[1]['Profilbild'] .. '|90x90px|verweis='.. queryResult[i][1] ..']]</div></td>'
end
i = i + 1
end
--tabelle schließen
returnString = returnString .. '</table>'
return returnString
end
return p