Module:Indicator datasets table: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 9: | Line 9: | ||
local ids = mw.text.split(articleids, ",") | local ids = mw.text.split(articleids, ",") | ||
local pagecontent = {} | local pagecontent = {} | ||
local titleobject | |||
for _, id in ipairs(ids) do | for _, id in ipairs(ids) do | ||
titleobject = mw.title.new(tonumber(id)) | |||
local existspage = titleobject.exists | local existspage = titleobject.exists | ||
Revision as of 14:18, 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 pagecontent = {}
local titleobject
for _, id in ipairs(ids) do
titleobject = mw.title.new(tonumber(id))
local existspage = titleobject.exists
if existspage then
local content = titleobject:getContent()
-- Speichere den Inhalt der Seite
table.insert(pagecontent, content)
else
table.insert(pagecontent, "Error: Page not found for ID " .. id)
end
end
-- Erstelle für jeden Inhalt ein <div>-Element
local result = {}
for _, content in ipairs(pagecontent) do
table.insert(result, '<div>' .. content .. '</div>')
end
-- Gib alle <div>-Elemente als zusammengefügten String zurück
return table.concat(result, "\n")
end
return p