Module:Indicator datasets table: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Manual revert |
No edit summary |
||
| Line 11: | Line 11: | ||
for _, id in ipairs(ids) do | for _, id in ipairs(ids) do | ||
local titleobject = mw.title.new( tonumber(id) ) | local 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 | 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 | end | ||
return p | return p | ||
Revision as of 14:16, 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 = {}
for _, id in ipairs(ids) do
local 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