Module:SMW

From devsummit
Revision as of 08:48, 27 November 2017 by Ccicalese (talk | contribs) (=p.sessionTable())

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