Module:SMW: Difference between revisions
From devsummit
No edit summary |
(=p.sessionTable()) |
||
Line 5: | Line 5: | ||
function p.sessionTable(frame) | function p.sessionTable(frame) | ||
local | local sessions = mw.smw.getQueryResult( "[[Category:Sessions]]" ) | ||
if | if sessions == nil then | ||
return "(no values)" | return "(no values)" | ||
end | end | ||
if type( | if type( sessions ) ~= "table" then | ||
return "(invalid query result)" | return "(invalid query result)" | ||
end | |||
local statements = {}; | |||
for k,v in pairs( sessions.results ) do | |||
statements[v.fulltext] = mw.smw.getQueryResult( "[[Category:Statements]][[Session::" .. v.fulltext .. "]]" ) | |||
end | end | ||
local myResult = "" | local myResult = "" | ||
for k,v in pairs( | for k,v in pairs( sessions.results ) do | ||
myResult = myResult .. "[[" .. v.fulltext .. "]]" .. "<br/>" | myResult = myResult .. "[[" .. v.fulltext .. "]]" .. "<br/>" | ||
end | end |
Revision as of 08:48, 27 November 2017
Documentation for this module may be created at Module:SMW/doc
-- Module:SMW
local p = {}
-- Return results
function p.sessionTable(frame)
local sessions = mw.smw.getQueryResult( "[[Category:Sessions]]" )
if sessions == nil then
return "(no values)"
end
if type( sessions ) ~= "table" then
return "(invalid query result)"
end
local statements = {};
for k,v in pairs( sessions.results ) do
statements[v.fulltext] = mw.smw.getQueryResult( "[[Category:Statements]][[Session::" .. v.fulltext .. "]]" )
end
local myResult = ""
for k,v in pairs( sessions.results ) do
myResult = myResult .. "[[" .. v.fulltext .. "]]" .. "<br/>"
end
return myResult
end
return p