Module:SMW: Difference between revisions
From devsummit
(Created page with "-- Module:SMW local p = {} -- Return results function p.ask(frame) if not mw.smw then return "mw.smw module not found" end if frame.args[1] == nil then...") |
No edit summary |
||
Line 23: | Line 23: | ||
for k,v in pairs( queryResult.results ) do | for k,v in pairs( queryResult.results ) do | ||
if v.fulltext and v.fullurl then | if v.fulltext and v.fullurl then | ||
myResult = myResult | myResult = myResult .. "[[" .. v.fulltext .. "]]" .. "<br/>" | ||
else | else | ||
myResult = myResult .. k .. " | no page title for result set available (you probably specified ''mainlabel=-')" | myResult = myResult .. k .. " | no page title for result set available (you probably specified ''mainlabel=-')" |
Revision as of 08:40, 27 November 2017
Documentation for this module may be created at Module:SMW/doc
-- Module:SMW
local p = {}
-- Return results
function p.ask(frame)
if not mw.smw then
return "mw.smw module not found"
end
if frame.args[1] == nil then
return "no parameter found"
end
local queryResult = mw.smw.getQueryResult( frame.args )
if queryResult == nil then
return "(no values)"
end
if type( queryResult ) == "table" then
local myResult = ""
for k,v in pairs( queryResult.results ) do
if v.fulltext and v.fullurl then
myResult = myResult .. "[[" .. v.fulltext .. "]]" .. "<br/>"
else
myResult = myResult .. k .. " | no page title for result set available (you probably specified ''mainlabel=-')"
end
end
return myResult
end
return queryResult
end
return p