Modul:UniquePropertyValuesCards: Unterschied zwischen den Versionen

Aus Stadtsprachen
Wechseln zu:Navigation, Suche
Keine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Keine Bearbeitungszusammenfassung
Markierung: Manuelle Zurücksetzung
 
Zeile 16: Zeile 16:
         table.insert(divs,  
         table.insert(divs,  
             '<div class="col-12 col-md-' .. colAmount .. ' text-center d-flex flex-column mb-1 px-1">' ..
             '<div class="col-12 col-md-' .. colAmount .. ' text-center d-flex flex-column mb-1 px-1">' ..
                 '<div class="card hover-card p-2 d-flex justify-content-center align-items-center" style="height: 100%;>' ..
                 '<div class="card hover-card p-2 d-flex justify-content-center align-items-center" style="height: 100%; background-color: #f5f5f5;">' ..
                     link ..  
                     link ..  
                 '</div>' ..
                 '</div>' ..

Aktuelle Version vom 10. März 2025, 13:26 Uhr

Die Dokumentation für dieses Modul kann unter Modul:UniquePropertyValuesCards/Doku erstellt werden

local uniqueValuesModule = require('Module:UniquePropertyValues')

local p = {}

function p.wrapValuesInDivs(frame)
    local propertyName = frame.args[1]
    local colAmount = frame.args[2] or "3"  -- Default to 3 if not specified
    
    -- Get unique values using the other module
    local uniqueValues = uniqueValuesModule.getUniqueValues(propertyName)
    
    -- Create a list of <div> elements with the specified structure
    local divs = {}
    for _, value in ipairs(uniqueValues) do
        local link = value  -- Use the value directly, which contains the wiki link
        table.insert(divs, 
            '<div class="col-12 col-md-' .. colAmount .. ' text-center d-flex flex-column mb-1 px-1">' ..
                '<div class="card hover-card p-2 d-flex justify-content-center align-items-center" style="height: 100%; background-color: #f5f5f5;">' ..
                    link .. 
                '</div>' ..
            '</div>'
        )
    end
    
    -- Return all <div> elements concatenated as a single string
    return table.concat(divs, "\n")
end

return p