Module:Indicator datasets table: Difference between revisions

From Visual Data Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
      
      
     local ids = mw.text.split(articleids, ",")
     local ids = mw.text.split(articleids, ",")
     local dates = {}
     local pagecontent = {}
      
      
     for _, id in ipairs(ids) do
     for _, id in ipairs(ids) do
Line 21: Line 21:
end
end
return table.concat(pagecontent, " - ")
return pagecontent
     end
     end
    
   return table.concat(pagecontent, " - ")
end
end


return p
return p

Revision as of 14:13, 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) )
		--Doesn't use a colon
		local existspage = titleobject.exists
		local pagecontent
		
		if existspage then
		-- Method uses a colon
		  pagecontent = titleobject:getContent()
		end
		
		return pagecontent
    end
   return table.concat(pagecontent, " - ")
end

return p