Sacra.Wiki Modul:RandomPerson: Unterschied zwischen den Versionen

Modul:RandomPerson: Unterschied zwischen den Versionen

Aus Sacra.Wiki
Markierung: Manuelle Zurücksetzung
 
(58 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
local p = {}
local p = {}


function p.ask()
function p.ask(frame)
if not mw.smw then
if not mw.smw then
         return "mw.smw module not found"
         return "mw.smw module not found"
end
end


local queryResult = mw.smw.ask("[[Kategorie:Person]]|?Bildname|limit=3|order=random")
local queryResult = mw.smw.ask("[[Kategorie:Person]][[Hat Bild::+]]|?Name|?Hat Bild|?Institution|?Funktion|limit=4|order=random")
if queryResult == nil then
if queryResult == nil then
         return "(no values)"
         return "(no values)"
    end
end
    if type( queryResult ) == "table" then
         local myResult = ""
local result = frame:extensionTag('templatestyles', '', { src = 'RandomPerson/style.css' })
if type( queryResult ) == "table" then
         local result = result..'<div class="people-container">'
         for num, row in pairs( queryResult ) do
         for num, row in pairs( queryResult ) do
             myResult = myResult .. '* This is result #' .. num .. '\n'
             result = result .. '<div class="random-person">'
            for property, data in pairs( row ) do
            if row["Hat Bild"] then
                local dataOutput = data
            result = result .. '[[File:'..row["Hat Bild"]..'|link=[['..row["Name"]..']]]]\n'
                if type( data ) == 'table' then
        else
                    dataOutput = mw.text.listToText( data, ', ', ' and ')
        result = result .. '[[File:Blank-profile-picture-g765c70dd2_640.png|link=[['..row["Name"]..']]]]\n'
                end
            end
                myResult = myResult .. '** ' .. property .. ': ' .. dataOutput .. '\n'
            result = result .. '<div class="random-person--name"><span>[[' .. row["Name"] .. ']]</span></div>'
            if row["Institution"] then
            result = result .. '<div class="random-person--description">Institution: ' .. row["Institution"] .. '</div>'
             end
             end
    if row["Funktion"] then
            result = result .. '<div class="random-person--description">Funktion: ' .. row["Funktion"] .. '</div>'
    end
            result = result .. '</div>\n'
         end
         end
         return myResult
         return result..'</div>'
     end
     end
end
end


return p
return p

Aktuelle Version vom 27. September 2022, 16:48 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]][[Hat Bild::+]]|?Name|?Hat Bild|?Institution|?Funktion|limit=4|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 = result..'<div class="people-container">'
        for num, row in pairs( queryResult ) do
            result = result .. '<div class="random-person">'
            if row["Hat Bild"] then
            	result = result .. '[[File:'..row["Hat Bild"]..'|link=[['..row["Name"]..']]]]\n'
        	else
        		result = result .. '[[File:Blank-profile-picture-g765c70dd2_640.png|link=[['..row["Name"]..']]]]\n'
            end
            result = result .. '<div class="random-person--name"><span>[[' .. row["Name"] .. ']]</span></div>'
            if row["Institution"] then
            	result = result .. '<div class="random-person--description">Institution: ' .. row["Institution"] .. '</div>'	
            end
    		if row["Funktion"] then
            	result = result .. '<div class="random-person--description">Funktion: ' .. row["Funktion"] .. '</div>'	
    		end
            result = result .. '</div>\n'
        end
        return result..'</div>'
    end
end

return p
Cookies helfen uns bei der Bereitstellung von Sacra.Wiki. Durch die Nutzung von Sacra.Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.