Module:Sandbox/Ste1la/Wikidata: Difference between revisions
< Module:Sandbox | Ste1la
imported>Ste1la No edit summary |
(No difference)
|
Latest revision as of 00:43, 1 December 2018
Documentation for this module may be created at Module:Sandbox/Ste1la/Wikidata/doc
local p = {}
p.propertyCall = function(frame)
local id = frame.args.id or ""
local propertyId = frame.args.property or ""
local articleName
local link = ""
local statementsTbl = mw.wikibase.getBestStatements(id, propertyId)
local linkList = {}
local out = ""
if #statementsTbl == 0 then
return ""
end
for k, v in pairs(statementsTbl) do
local id = v.mainsnak.datavalue.value.id
if mw.wikibase.getSitelink(id) then
articleName = mw.wikibase.getSitelink(id)
else
articleName = mw.wikibase.getLabel(id)
end
if articleName:find("%(") then
i, j = articleName:find("%(")
update = articleName:sub(1, i - 1)
articleName = articleName .. "|" .. update
end
add = "[[" .. articleName .. "]]"
table.insert(linkList, add)
end
out = table.concat(linkList, "<br>")
return out
end
return p