Module:Indicator datasets table: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 19: | Line 19: | ||
local pagecontent = titleobject:getContent() | local pagecontent = titleobject:getContent() | ||
local jsonData = mw.text.jsonDecode(pagecontent) | local jsonData = mw.text.jsonDecode(pagecontent) | ||
table.insert(dates, tonumber(id)) | |||
else | else | ||
table.insert(dates, "Error: Seite nicht gefunden für ID " .. id) | table.insert(dates, "Error: Seite nicht gefunden für ID " .. id) | ||
Revision as of 14:03, 2 May 2024
Documentation for this module may be created at Module:Indicator datasets table/doc
local p = {}
function p.getDatasets(frame)
local articleids = frame.args.articleids
if not articleids then
return "Error: articleids not provided"
end
local ids = mw.text.split(articleids, ",")
local dates = {}
for _, id in ipairs(ids) do
local titleobject = mw.title.new( 562 )
if titleobject then
local existspage = titleobject.exists
if existspage then
local pagecontent = titleobject:getContent()
local jsonData = mw.text.jsonDecode(pagecontent)
table.insert(dates, tonumber(id))
else
table.insert(dates, "Error: Seite nicht gefunden für ID " .. id)
end
else
table.insert(dates, "Error: Fehler beim Erstellen des Titels für ID " .. id)
end
end
return table.concat(dates, ", ")
end
return p