Module:ExternalCatalogueLinks

From The Seven Sages of Rome
Revision as of 13:41, 26 February 2026 by Noeth (talk | contribs) (Created page with "-- Module:ExternalCatalogueLinks local p = {} function p.render(frame) local pagename = frame:preprocess("{{PAGENAME}}") local results = mw.smw.ask({ "- Has subobject::" .. pagename .. "", "?Has External Catalogue Title", "?Has External Catalogue Link" }) if not results or #results == 0 then return "" end local items = {} for _, row in ipairs(results) do local title = row["Has Ex...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:ExternalCatalogueLinks/doc

-- Module:ExternalCatalogueLinks
local p = {}

function p.render(frame)
    local pagename = frame:preprocess("{{PAGENAME}}")
    
    local results = mw.smw.ask({
        "[[- Has subobject::" .. pagename .. "]]",
        "?Has External Catalogue Title",
        "?Has External Catalogue Link"
    })
    
    if not results or #results == 0 then
        return ""
    end
    
    local items = {}
    
    for _, row in ipairs(results) do
        local title = row["Has External Catalogue Title"]
        local link = row["Has External Catalogue Link"]
        
        if title and link then
            table.insert(items, "[" .. link .. " " .. title .. "]")
        elseif title then
            table.insert(items, title)
        end
    end
    
    return table.concat(items, ", ")
end

return p